Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Ensuring only one copy of a perl script is running at a time

by tokpela (Chaplain)
on Mar 25, 2011 at 00:13 UTC ( #895367=note: print w/ replies, xml ) Need Help??


in reply to Ensuring only one copy of a perl script is running at a time

On Windows, I used Win32::Mutex to ensure that a process was not already running.

However, I seem to remember that this only worked on a per user basis and did not prevent another user from running the same script. But since I was running using a scheduled task, it worked well.


Comment on Re: Ensuring only one copy of a perl script is running at a time
Re^2: Ensuring only one copy of a perl script is running at a time
by Anonymous Monk on Mar 27, 2013 at 04:28 UTC
    What about?

    $cmd = 'ps -eaf | grep -c "\< '."$0".'\>"'; chomp($instances = `$cmd`); if($instances > 1) exit;

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2014-12-26 01:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (163 votes), past polls