Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Cron Jobs That Run For Too Long

by ikegami (Patriarch)
on Dec 20, 2005 at 20:11 UTC ( [id://518175]=note: print w/replies, xml ) Need Help??


in reply to Cron Jobs That Run For Too Long

My first thought was to write a file to disk (a lock) and remove it on exit - so the next process will know to die... but what happens if it quits (or is killed) without removing the lock? Then nothing runs...

When a process dies, the OS removes any and all flock locks placed by it. Instead of checking for the existance of a lock file, check if there's a lock on it (after unconditionally creating the file).

Checking for existance is flawed anyway. For example,

Process 1 Process 2 ----------------------------- ----------------------------- die if -e $lockfile; die if -e $lockfile; open(my $fh, '>', $lockfile); # I think I hold the lock. open(my $fh, '>', $lockfile); # I think I hold the lock. . . .

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://518175]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-24 01:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found