------ art_33784_21626649.1159539678859 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 9/29/06, Krishna Dole <dontfall / gmail.com> wrote: > > Hi all, > If anyone is willing, I'd be grateful for some advice on the forking > job scheduler I've written. It works fine in simple tests, but does > not feel elegant. On IRC kbrooks recommended an asynchronous main > loop, but i don't understand how to implement that in this situation. > The first version I wrote used threads, but several sources > recommended fork instead. I have also considered just using the shell > command 'ps' to see how many jobs are running, launching more as > needed. > > The basic requirements: > - Each job is a long-running external process (taking a day or more) > and all jobs require a different amount of time to run (so > asynchronous launching will be needed). > - I want to keep N jobs running at all times (N in the example below) You say nothing about the coordination requirements of the external processes with the "watchdog" process. Is your requirement really just to ensure that four jobs are running at all times? If so, I would avoid using a long-running watchdog process, because you're making an assumption that it will never crash, catch a signal, etc. Why not run a cron job every five minutes or so that checks the running processes (via pgrep or ps as you suggested), starts more if necessary, writes status to syslog, and then quits? Much, much easier. ------ art_33784_21626649.1159539678859--