Script::Singleton - Ensure only a single instance of a script can run
use Script::Singleton; # Yep, that's it!
Using shared memory, this distribution ensures only a single instance of any script can be running at any one time.
There are no functions or methods. All the work is performed in the use line.
This software uses IPC::Shareable for the shared memory management, specifically its singleton() method.
use Script::Singleton;
Using it in the default, basic fashion, we'll create an IPC identifier (glue) using the full path and name of the calling script. We also won't output any warnings if a second instance of the script attempts to run before the initial run has completed and released the lock.
use Script::Singleton glue => 'UNIQUE GLUE STRING';
That will use UNIQUE GLUE STRING as the IPC glue. The glue parameter can be used in conjunction with the warn parameter.
use Script::Singleton warn => 1;
If the warn parameter is sent in with a true value, we'll emit a warning if a second instance of the script is run. The warn parameter can be used in conjunction with the glue parameter.
warn
Steve Bertrand, <steveb at cpan.org>
<steveb at cpan.org>
Copyright 2021 Steve Bertrand.
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
http://www.perlfoundation.org/artistic_license_2_0
To install Script::Singleton, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Script::Singleton
CPAN shell
perl -MCPAN -e shell install Script::Singleton
For more information on module installation, please visit the detailed CPAN module installation guide.