I have a worker program which I start in rc.local. The program is not the most stable in the world so I would like to set up a watcher of some kind that checks to see if the aforementioned program is chugging along and if not, start up the program again.
I can imagine a couple of ways to do this, although I am sure there are more:
- have a cron job that runs and looks for the running program. If there, it stops, otherwise it fires off another instance of the program
- run a dedicated monitoring program that runs all the time and polls frequently to see if the program is running.
Do any of you have examples of either of these implementations or recommendations on how I should do this?