in reply to Check for another running instance of the same program
There are many ways to ensure single instance of perl program is running. PID files are the traditional way to do it. we can also hold a lock on a file,for example the program itself. This small piece of code will do the trick:
use Fcntl ':flock';
open my $self, '<', $0 or die "Couldn't open self: $!";
flock $self, LOCK_EX | LOCK_NB or croak "This script is already runnin
One advantage over PID files is that files automatically get unlocked when the program exits. It is much easier to implement in a reliable way.
All is well