* * * * * /path/to/program
* * * * * sleep 30; /path/to/program

Don't forget to write something into your program so that it exits if a previous instance is already running.


if ln -s "pid=$$" /var/pid/; then
  trap "rm /var/pid/" 0 1 2 3 15
  echo "Already running, or stale lockfile." >&2
  exit 1

Of course, this still leaves a very small opportunity for failure, so search google for a better solution applicable to your environment.

  • 0
Reply Report

Cron is designed to wake up at every minute, so it is not possible to do it without some hacking, for example sleep like you mentioned.

  • 0
Reply Report
  • 0

If your task needs to run that frequently, cron is the wrong tool. Aside from the fact that it simply won't launch jobs that frequently, you also risk some serious problems if the job takes longer to run than the interval between launches. Rewrite your task to daemonize and run persistently, then launch it from cron if necessary (while making sure that it won't relaunch if it's already running).

  • 0
Reply Report


Related Questions

Trending Tags