Ben Oliver

technology

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

Takes the hassle out of automating large backups
24 March 2015

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-one1 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 lots2 of ways3 to do this, but they are long winded4. This couldn’t be simpler.

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

http://blog.dustinkirkland.com/2011/02/introducing-run-one-and-run-this-one.html6

Reply by email