#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    74
    Rep Power
    11

    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.

    Thank you.
  2. #2
  3. Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Dec 2004
    Location
    Meriden, Connecticut
    Posts
    1,797
    Rep Power
    154
    Did you even try using os.system() to see how it worked out?
  4. #3
  5. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    174
    Rep Power
    11
    dejavu?

    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.

    dejavu again?
    sf2k
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2005
    Posts
    174
    Rep Power
    11
    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

IMN logo majestic logo threadwatch logo seochat tools logo