run-one - ensure your cron jobs end before they repeat

Takes the hassle out of automating large backups

One of the main reasons I use cron is for backups. I can tell my server to perform an rsync operation at 0100 every day to make a copy of everything.

The problem with this is when you hit a large backup that takes more than one day to run. Cron doesn’t know Tuesday’s backup hasn’t finished, and sets off Wednesday’s in duplicate. This is not a good idea.

run-one solves that problem in one fell swoop. It locks the process, preventing it from being run twice until it’s done. To invoke it, one simply places the command run-one before their main operation. For example:

run-one rsync -aP --delete /my/cool/stuff /all/backed/up/

Easy! Put that line in your cron tab and you’re off.

There are lots of ways to do this, but they are long winded. This couldn’t be simpler.

I got it from the AUR, but it seems like most distros have it available.