http://qs321.pair.com?node_id=11148532


in reply to Mechanism for ensuring only one instance of a Perl script can only run?

Hi redapplesonly!

You could use a pid file for that. This is, as far as I know, the mechanism commonly used by server software.

At start up, Your script checks if there is already a file with a given name, usually yourscript.pid in a directory, usually /var/run. If there is one it may read the contents which would be the process id of the already running instance and print an error and exit.

.

If there is none, Your script would create yourscript.pid and write its pid to it. Before the script exits, it deletes the file.