Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re^2: Cron Jobs That Run For Too Long

by ruoso (Curate)
on Dec 20, 2005 at 22:07 UTC ( #518197=note: print w/replies, xml ) Need Help??

in reply to Re: Cron Jobs That Run For Too Long
in thread Cron Jobs That Run For Too Long

Just a note, adding to what sgifford said...

I've seen some scripts around listing /proc to check if the process is still running. I prefer to use a kill 0 on the proccess...

And I, personally, prefer the second way because it can be used for lockfiles even if the only place you can write the lockfile can't provide locking, or the locking isn't reliable (NFS)


Replies are listed 'Best First'.
Re^3: Cron Jobs That Run For Too Long
by adamk (Chaplain) on Dec 20, 2005 at 23:22 UTC
    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.


    use strict;
    use Fcntl 'LOCK_EX', 'LOCK_NB';

    unless ( flock DATA, LOCK_EX | LOCK_NB ) {
        print STDERR "Found duplicate script run. Stopping\n";




    This exists to allow the locking code at the beginning of the file to work.

      hey, that's really nice.
      11 years later this is still brilliant.
      this works great!!! can you give explenations on the __DATA__ part? I dont have a clue what is this for... Roy

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://518197]
[Sinistral]: I think that just the sight of his username now causes a downvote storm. I agree, and the gratuitous use of formatting does make reading hard. I've given him +1 on things where there seemed to be actual good advice, but I think the big
[Sinistral]: nail in coffin was the rant against a Schwarzian Transform
[stonecolddevin]: at best, from what i've seen, his knowledge is accurate up to maybe 2002. the sheer volume of words is mostly worthy of a downvote in most cases though i think
[erix]: ITYM Schwartzian Transform :P
[erix]: hey planetscape :)
[planetscape]: howdy stonecolddevin, erix
[Sinistral]: eric Aye. I thought I typed that wrong. All hail Randall! I listen to him on FLOSS Weekly
[Discipulus]: i think his vacuus, trombon like, absence of meaning, joined with a ostentatious style, after many years irritates the most
[erix]: easy to get wrong -- I guess that was sund's point, too :P
[Discipulus]: planetscape welcome back! (or is well comeback?)

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (10)
As of 2017-06-22 20:56 GMT
Find Nodes?
    Voting Booth?
    How many monitors do you use while coding?

    Results (530 votes). Check out past polls.