Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

There is a stub application written in C. Now I want to run this application periodically, say at 11.30am daily. I thought of using the cron process but I don't know how to do it. Please help.

Also I want the cron to periodically check if the application is running normally or not. If the application crashes or hangs, cron should be able to restart the application within a certain period of time.

share|improve this question

Cron is for running scheduled tasks at scheduled intervals, not baby sitting other processes.

You could either:

  • use something different such as the init script system of your host OS, perhaps with a custom job in inittab that will respawn itself if it dies.

  • or hack something together in the form of a shell script that periodically gets fired off by cron that checks up on your daemon script using some set of pre-determined checks for whether it is running properly or not, and if not cleans up after it then re-launches.

share|improve this answer

You can just make an entry in your crontab file

$ crontab -e

end then your entry according to http://www.manpagez.com/man/5/crontab/

30 11 * * * /path/to/your/command

With the MAILTO entry you will receive an email if the command produces output on STDERR

Checking if the process hangs is more difficult: you should define what do you mean by hangs: runs more than a certain time? Produces some recognizable behavior?

You can always have a second process or script running at a later time to check if the process is still running and take appropriate action.

share|improve this answer

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.