If it starts and stops every few minutes (e.g. as a cron job) rather than running in the background, the easiest way to keep track is probably to write a file somewhere that contains any relevant data you care to keep track of. If you just want to know when the last time you sent an email, you might be able to use the last-modified date of the file (and just "touch" it each time you send an email). If you want to store more information, you can store the time and any diagnostic information (e.g. last event time). Be sure to pay attention to what the running environment is- background jobs often run in a different environment than the user that created them and you need to specify full pathnames for files.