September 13th, 2005, 03:23 PM
finding a unix process
I have a script which runs all day and I want to detect if it has died. I want to make another python script which runs off of cron and checks to see if this process is running every so often. How can I search to see if this particular script is currently running? I imagine I can do it with a series of os.system() commands using grep and search through the results, but since I am pretty new to this I didn't know if there was an easier more elegant way of doing it. I have seen examples for win32 processes, but not unix which I am on.
September 13th, 2005, 06:19 PM
Did you even try using os.system() to see how it worked out?
September 14th, 2005, 01:17 AM
grep the ps program at regular intervals via cron for the data you want into a text file then do whatever you like via sed (or with python and the regular expression module re).
I'm really really sure that I've seen this exact question here as another thread, as a python version, but maybe I'm not using the right search terms? ... anyway
if i remember incorrectly, it was using the modules time, re, and exec or somthing to run some *nix commands then the data was dumped into python for parsing.
September 14th, 2005, 01:29 AM
try this thread: not what I was looking for, but has some points that should help you out... http://forums.devshed.com/t227876/s.html