I want to run a cron every 5 minutes, but I don't want the next cron to run if the previous did not finish yet.
What can be done about this? Are there any tools to support this?
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
flock -n /path/to/lockfile -c "command_you_want_to_run"
You can use the run-one command. It automatically creates a lock file for the command being run.
run-one rsync -a mirror.kernel.org::everything /my/hd
The behavior is similar to flock, but the syntax is more clear. The downside is that you might need to install the command to use it. Also, special attention should be paid when modifying the command line, when the command line changes, so does the lock file name
Cron does not support any type of job dependancies. The entries you put in there run when specified.
You are going to have to put in some simple interlocking scheme. Putting the given command or set of commands in a wrapper script containing the locking scheme.
Or as larger sites do, install some type of job scheduling applications and use that to run the applications with conditions.