ajwood has asked for the wisdom of the Perl Monks concerning the following question:
I have a script that spawns some children. They all take quite a while to run, creating directories and files along the way. I often notice things I'd like to change before the children die of natural causes, so then I have to shut everything down (which involves a few `grep` and `kill` calls) and delete any files the children created. It's not really a big deal, but a bit of a pain in the neck. I'd like to create a setup where the children are all monitored so when I start up the parent again, old children still running are reported.
My best idea so far is keeping a log file of children I've run with their PIDs, checking it and updating it every time the parent starts up. Kill and report any children still running, and die to let the user clean up directories and files by hand before a fresh run.
So my first question is this: Do any of you experts out there have a nicer solution than what I described?
Second, if this is a good way to go about it, what would be my best bet for adding children to the log file? Is there a way to set up a trigger which could automatically take care of it, or am I stuck having to remember to do it any place in the code where a new process starts up?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Keeping track of children from previous runs of a script
by salva (Canon) on Mar 10, 2011 at 17:28 UTC | |
by Illuminatus (Curate) on Mar 10, 2011 at 17:40 UTC | |
by salva (Canon) on Mar 10, 2011 at 18:00 UTC | |
by JavaFan (Canon) on Mar 10, 2011 at 18:33 UTC | |
|
Re: Keeping track of children from previous runs of a script
by atcroft (Abbot) on Mar 10, 2011 at 17:14 UTC | |
|
Re: Keeping track of children from previous runs of a script
by anonymized user 468275 (Curate) on Mar 10, 2011 at 17:48 UTC |