[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

cron jobs to restart a shell process ...



~
 Sometimes I need to start a long running process which for various reasons may
be stopped (server drops connection, OS kills it, ...) and I would like to have
a somewhat automatic mechanism to check if it was stopped and, in that case,
restart it (of course, with a new process id)
~
 This is what I have in mind:
~
 1) run an initial script to set up the context of the long running process,
which, of course, will be specific, but the communication between 1) and 2) is
just trough a regular protocolled file (I try to make my code as compatible as
possible and pipes and other forms of interprocess comm tend to be very OS
specific).
~
 2) a second general script which based on 1) and the id of the running process
just checks if process is running and restarts it in the case it
isn't, based on:
~
 2.1) a lock file named after some identifying metadata regarding 1), and
~
 2.2) containing the current/last process id.
~
 3) insert a line in your crontab file, to run 2)
~
 You can check if a process is running by pars-, greping ps aux's output and
simply go monkey to finish some working script, but I am sure those needs aren't
just mine and there should be either a flag for cron jobs, a utility, or some
best practices out there I don't know of. In fact, do you know of best practices
for max data processing (I am talking here about jobs that may take days)
~
 Is there such a thing?
~
 Any suggestions?
~
 thank you,
 lbrtchx


Reply to: