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?
In reply to Keeping track of children from previous runs of a script by ajwood
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |