GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Sys::RunAlways(3) User Contributed Perl Documentation Sys::RunAlways(3)

Sys::RunAlways - make sure there is always one invocation of a script active

 use Sys::RunAlways;
 # code of which there must always be on instance running on system

 use Sys::RunAlways silent => 1;  # don't tell the world we're starting
 # code of which there must always be on instance running on system

Provide a simple way to make sure the script from which this module is loaded, is always running on the server.

This documentation describes version 0.06.

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 "flock"ed, it exits silently with an exit value of 0.

If there is a DATA handle, and it could be "flock"ed, a message is put on STDERR and execution continues without any further interference. Optionally, the message on STDERR can be prevented by specifying the "silent" parameter in the "use" statement with a true value, like:

  use Sys::RunAlways silent => 1;

 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.

If you change the script while it is running, the script will effectively lose its lock on the file. Causing any subsequent run of the same script to be successful, causing two instances of the same script to run at the same time (which is what you wanted to prevent by using Sys::RunAlone in the first place). Therefore, make sure that no instances of the script are running (and won't be started by cronjobs while making changes) if you really want to be 100% sure that only one instance of the script is running at the same time.

Inspired by Randal Schwartz's mention of using the DATA handle as a semaphore on the London PM mailing list.

Sys::RunAlone.

 Elizabeth Mattijsen

maintained by LNATION, <thisusedtobeanemail@gmail.com>

Copyright (c) 2005, 2006, 2012 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.
2019-11-06 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.