Super User is a question and answer site for computer enthusiasts and power users. 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 am setting up an rsync backup job on linux (ubuntu 11.10 server). If the backup runs long, and is still running when the next scheduled time comes up, will cron start another instance of rsync? Or will it hold off as the existing process is still running?

The content of the job is really not relevant, more a question of how cron tracks jobs, or if it does so at all.

share|improve this question
up vote 4 down vote accepted

Yes they will double up. See here for more detail on how to stop that from happening.

The basic idea is to create something that can only be done by one process at a time, and if the cron job can't do it, then it quits. Locking a file is the common way of doing it, as if a file is locked, another process (or cron job in this case) cannot lock the same file.

share|improve this answer
...which can be done using flock -x -w120 /run/backup.lock rsync ... in the cronjob. (-w120 will cause it to wait for the previous job's completion for up to 120 seconds, and -n would cause it to skip immediately.) – grawity Nov 27 '11 at 19:59

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.