SPUG: Perl Question?
Andrew Sweger
andrew at sweger.net
Wed May 4 11:41:06 PDT 2005
On Wed, 4 May 2005, jerry gay wrote:
> you might instead consider one of my favorite locking hacks:
>
> #!/usr/bin/perl
> ...
> ## ensure only one instance of this script is running
> INIT { flock DATA => LOCK_EX | LOCK_NB or exit 1 }
> ...<script body here>...
> __DATA__
>
> which will exit if the script can't get an exclusive lock on itself.
> no messy lockfiles to worry about.
Now that's a cool trick. Thanks!
--
Andrew B. Sweger -- The great thing about multitasking is that several
things can go wrong at once.
More information about the spug-list
mailing list