I run a process that sometime crash and sometime freeze. I used supervise to have it automatically restart when it crash. However, if it freeze, it stay frozen until I am back in front of the computer. I would like a tool that would restart it when it crash, but can also be configure to do periodic kill and restart, so if it freeze, it won't stay frozen more that a given period of time.
Which tool would who suggest?
I tried using supervise from daemontools with a crontab :
First, I start with
and I use this crontab :
0 23 * * * svc -d /fullpath
2 23 * * * svc -k /fullpath
5 23 * * * svc -u /fullpath
Where fullpath is the directory containing the file called run which start my process. The tricky part is the file called should end with :
exec java ...
Normally, I start the application with a script, but if I put that script in the file called run, when svc is executed, it send the signal to the script and the java process continue to run. I created a copy of the script and modified it to make it output the call to java with all parameter, and copied this in the file called run.
You could use cron to do this if you want...
sudo crontab -e
* /5 * * * pkill -9 <your process name here> ; <your process name here>
Would kill and restart it every 5 hours. More examples... Cron examples