Server Fault is a question and answer site for system and network administrators. 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

So I got a number of small cronjobs, that needs to run more frequent then a minute. So what I usually do is - create shell script with a while loop and sleep statements in it. And then I run it in a screen session.

The problem of course is that it does not start if the server is restarted, also it is not as flexible as init.d scripts.

I checked a number of posts around but there are mainly not so convenient work-around, and I am trying to avoid those.

Is there some platform, or a template I can just pop my while loop into and run it as init.d script ? Or maybe some other convenient solution ?

share|improve this question
up vote 0 down vote accepted

My suggestion would be to add some file lock and checking to your script . Cronjob checks if there is file lock created by process inside while loop; if there is nothing happens; if there isn't one start a process in while loop.

In addition to that, you may find special cron directive/alias '@reboot' useful to start these processes immediately when system boots/reboots.

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.