Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|improve this question
The process is a java process. pkill java won't work, since they are other java process I don't wish to kill. – Guillaume Coté Mar 26 '13 at 1:13
up vote 0 down vote accepted

I tried using supervise from daemontools with a crontab :

First, I start with

supervise /fullpath

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.

share|improve this answer

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

share|improve this answer
It would, but it won't supervise it. I want a tool that boot supervise it and restart it. – Guillaume Coté Mar 26 '13 at 0:12
pkill java might kill the wrong process. – Guillaume Coté Mar 26 '13 at 1:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.