Sys::RunAlone - make sure only one invocation of a script is active at a time
use Sys::RunAlone; # code of which there may only be on instance running on system
Provide a simple way to make sure the script from which this module is loaded, is only running once on the server.
There are no methods.
The functionality of this module depends on the availability of the DATA handle in the script from which this module is called (more specifically: in the "main" namespace).
At INIT time, it is checked whethere there is a DATA handle: if not, it exits with an error message on STDERR and an exit value of 2.
If the DATA handle is available, and it cannot be flocked, it exits with an error message on STDERR and an exit value of 1.
flock
If there is a DATA handle, and it could be flocked, execution continues without any further interference.
Fcntl (any)
Execution of scripts that are (sym)linked to another script, will all be seen as execution of the same script, even though the error message will only show the specified script name. This could be considered a bug or a feature.
Inspired by Randal Schwartz's mention of using the DATA handle as a semaphore on the London PM mailing list.
Sys::RunAlways.
Elizabeth Mattijsen
Copyright (c) 2005 Elizabeth Mattijsen <liz@dijkmat.nl>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Sys::RunAlone, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sys::RunAlone
CPAN shell
perl -MCPAN -e shell install Sys::RunAlone
For more information on module installation, please visit the detailed CPAN module installation guide.