http://www.perlmonks.org?node_id=895367


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

Replies are listed 'Best First'.
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;