to ensure that if the job occasionally takes a long time to run, we don't accidentally cause a backlog by starting it over and over again. Sounds simple? Well, it's short, but the details are pretty tricky. Let's go through the source code and look at some of its interesting parts. #!/usr/bin/perl -w use strict; use LockFile::Simple; You probably want to know about the LockFile::Simple perl module. It does pretty much everything you want to do with lockfiles. Unfortunately, its defaults are insane and will get you into a ton of trouble if you use them. It's pretty obvious that the author of this module has learned a lot over time. Above we check to make sure the argument list is okay. Nothing too special here, except for one thing: we return 127 in case of an error, because the more common error codes might be returned by the subprogram we're running. runlock is intended to be used whenever you might normally run the given program directly, so it's important not to eat the return code of the subprogram. Here's the first tricky bit: the correct options to LockFile::Simple. "-stale=&gt;1" means that we should "automatically detect stale locks." Now, this sounds like it's obviously a good thing, but is for some reason not the default. The way this sort of lockfile works is that you use a set of atomic operations to write your pid (process id) to the lockfile. Then, other programs that want to check if the lock