I use this little program for shell-level locking, to ensure that only one invocation of a given program runs at a time.

It just checks for a pid file. If the pid file does not exist, or the pid no longer exists, it'll start the process (program), and write the new process' pid to the pid file.

It's at:
https://stromberg.dnsalias.org/svn/just-one/trunk/

...and usage looks like:

The "string" part needs to be a unique identifier for each process you want only one of. The command, naturally, is a shell command.

It does not use locking: advisory or mandatory. Just a lock file containing a pid.

EG:




Hits: 741
Timestamp: 2024-04-27 17:26:47 PDT

Back to Dan's tech tidbits

You can e-mail the author with questions or comments: