|
|
| There's more than one way to do things | |
| PerlMonks |
Re^3: Cron Jobs That Run For Too Longby adamk (Chaplain) |
| on Dec 20, 2005 at 18:22 UTC ( [id://518209]=note: print w/replies, xml ) | Need Help?? |
This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.
But wait, it gets better again! You know how you can have that nifty __DATA__ block at the end of your script? It turns out you can lock that too :) I've used this a number of times and it works just great. #!/usr/bin/perl use strict; use Fcntl 'LOCK_EX', 'LOCK_NB'; unless ( flock DATA, LOCK_EX | LOCK_NB ) { print STDERR "Found duplicate script run. Stopping\n"; exit(0); } ... 1; ### DO NOT REMOVE THE FOLLOWING LINES ### __DATA__ This exists to allow the locking code at the beginning of the file to work. DO NOT REMOVE THESE LINES!
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||||||||||||||