Cron - Any advanced options?

Dave Ihnat dihnat at dminet.com
Thu Apr 23 16:16:20 UTC 2009


On Thu, Apr 23, 2009 at 09:03:43AM -0700, Brian Fox wrote:
> An exit is probably better than sleeping.

Especially given that it's going to run again in 7 minutes.

> I like the lockfile except for the need for a watchdog.  Something about
> "write the script correctly and you won't need a watchdog" never seems to
> apply in real life.

The usual way to handle this in Unix/Linux is to write your PID in the
lockfile.  The checking routine can then verify that the PID is still
active, in which case it honors the lock, or it's gone, and it can take
steps to remove the stale lockfile.  Avoids the need for a watchdog.

The only real problem with a lockfile is concurrency--just creating a
normal file, it's possible to hit the window between check and creation
with another process.  Unlikely, but.  That's why I like using a
semaphore.  Hmm...I see there's a 'lockfile' command now in Linux.
Don't know how good it is, but it's probably better than RYO.

Cheers,
--
	Dave Ihnat
	ignatz at dminet.com




More information about the redhat-list mailing list