Solo is an interesting little Perl script:
solo is a very simple script (10 lines) that prevents a program from running more than one copy at a time. It is useful with cron to make sure that a job doesn’t run before a previous one has finished.
* * * * * solo -port=3801 /usr/local/bin/awesome-script.sh blah blah
The clever part is the use of binding to TCP ports to ensure that only one copy of the script is running at a time. No more lockfiles or filesystem tricks, just let the kernel figure out if the port is already in use.
4 replies on “Solo”
[…] use a framework like Gearman, but for simple things, I like very simple solutions. I came across a blog post by Joseph Scott about a little 10 line perl script called solo. What it does is it will run a command, and to […]
[…] years ago I mentioned Solo, which uses TCP/IP port binding to prevent a program from running more than […]
Hi,
I would suggest to release and PHP implementation of this tiny tool.
I feel this necessary because for example when you want to implement such “locking” in jailed environment where only PHP is available you won’t be able to do it as perl is missing.
Thanks!
The source for the Perl script is linked in the post. Porting it to other languages shouldn’t be too bad if you don’t have the option of having Perl available.