Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 have a number of services in init.d that are simple one-line commands wrapped in a script that repeats every few seconds. The template for them looks like this:


autostart() {
    while true
            $@ ; sleep 20

case "$1" in
            echo " started"
            autostart /path/to/checksomethingquickly
            me=`basename $0`
            killall checksomethingquickly $me

## End of File

The crux of this "service" is to call checksomethingquickly every 20 seconds. (Hence it's too quick for cron.) We want it to start when told to, and kill any/all running instances when it's told to stop.

It looks to me like it could be a "Task Job" in upstart but I'm unclear on how to ensure that the Task is repeated indefinitely and separated by 20 seconds. Ensuring it's serialised would be a nice improvement, too.

Is this the kind of script that can be turned into a upstart script? If so, how?

share|improve this question

Your Answer


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

Browse other questions tagged or ask your own question.