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: 955
Timestamp: 2024-12-27 07:46:13 PST

Back to Dan's tech tidbits

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