knbknb has asked for the wisdom of the Perl Monks concerning the following question:
Honorable monks,
I am seeking a solution to the following problem:
I have a script that runs in "demon mode" on a server, and does something every 10 seconds or so. More specifically, it looks for new files, and if it has found some, it does something else, and then copies files from folder A to folder B.
The script makes use of GetOpt::Long.
The script is not very bulletproof, though.
Occasionally I want to perform a one-off task, i.e. calling the same script with some other options, e.g. to move files from C to D.
If the script I am using for the one-off task is identical with the instance of the running script, it should immediately exit without doing any further work. If the options are different, it should perform its task. If the one-off task is already running, another attempt to run a second instance should fail.
How can I detect the command line options the permanently-running script has been called with? Is there a best way to do this? Has this problem been solved before (maybe with a special-purpose variant of GetOpt::Long or some obscure feature of GetOpt::Long) Just grab the %opts hash and compare entries?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Detect options of script runnning in a demon mode
by tirwhan (Abbot) on Feb 12, 2008 at 11:04 UTC | |
|
Re: Detect options of script runnning in a demon mode
by andreas1234567 (Vicar) on Feb 12, 2008 at 11:33 UTC | |
|
Re: Detect options of script runnning in a demon mode
by pc88mxer (Vicar) on Feb 12, 2008 at 16:09 UTC | |
|
Re: Detect options of script runnning in a demon mode
by knbknb (Acolyte) on Feb 13, 2008 at 09:26 UTC |