Author image Steve Bertrand


Script::Singleton - Ensure only a single instance of a script can run

Coverage Status


    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.

Custom glue

    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.


Steve Bertrand, <steveb at>


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: