You can use an 'Application Handler' to register code to run after certain events in blender, like rendering, saving, loading files and several other situations.
For example, in the code below, appending the function to the
save_pre handler would print out "Saving File" just before the file is saved:
If you wanted code to execute after the file is saved then you would append to
I am not too sure how you would execute code periodically, though there is a
scene_update_post which runs whenever the scene needs to be updated that you could look into.