471,335 Members | 1,492 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,335 software developers and data experts.

still get a <defunct> using a python script in the crontab

H!

I have made a program that is checking if a program is running or not.
If the program is not running then it must start the program again.

in the /etc/crontab:
* * * * * root /usr/sbin/
program_prgchk

in the /usr/sbin/program_prgchk:
/usr/local/bin/python /home/reseller/domeinaanvraag/program_prgchk.py
in the program_prgchk.py:
----------------------------------------
import string
import os
import commands

def checkifrunning():
line = string.strip(commands.getoutput("ps x -o pid,command | grep
program_reseller.py | grep -v 'grep'"))
pid = string.split(line,' ')[0]
if pid<>'':pid = int(pid)
return pid

if checkifrunning()=='':
os.system('/usr/sbin/program_reseller')
# os.wait()
# os.waitpid(checkifrunning(),0)

os._exit(0)
If I run the command /usr/sbin/program_prgchk everything works (no
<defunctprocess)
But when I use it in the crontab I get a <defunctprocess

Thanks for helping,
GC-Martijn

Sep 19 '07 #1
2 3779
If I run the command /usr/sbin/program_prgchk everything works (no
<defunctprocess)
But when I use it in the crontab I get a <defunctprocess
The crontabs file on my system is stored in /var/spool/cron/
crontabs/. It appears you are checking the wrong file. Try a
"crontab -e" from the command line and compare it to the contents in
the /etc/crontab file.

Sep 19 '07 #2
On 19 sep, 16:50, Zentrader <zentrad...@gmail.comwrote:
If I run the command /usr/sbin/program_prgchk everything works (no
<defunctprocess)
But when I use it in the crontab I get a <defunctprocess

The crontabs file on my system is stored in /var/spool/cron/
crontabs/. It appears you are checking the wrong file. Try a
"crontab -e" from the command line and compare it to the contents in
the /etc/crontab file.
The crontab is working because I can see that he started the
os.system('/usr/sbin/program_reseller') AND a <defunctprocess (what
I can only kill by killing the '/usr/sbin/program_reseller'

Sep 19 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

65 posts views Thread by Anthony_Barker | last post: by
3 posts views Thread by Gerard Oberle | last post: by
6 posts views Thread by Eric Enright | last post: by
5 posts views Thread by Bob MacBob | last post: by
8 posts views Thread by Old VB6 Guy | last post: by
45 posts views Thread by n.estner | last post: by
3 posts views Thread by yawnmoth | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.