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

M

martijn

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
<defunct> process)
But when I use it in the crontab I get a <defunct> process

Thanks for helping,
GC-Martijn
 
Z

Zentrader

If I run the command /usr/sbin/program_prgchk everything works (no
<defunct> process)
But when I use it in the crontab I get a <defunct> process

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.
 
M

martijn

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 <defunct> process (what
I can only kill by killing the '/usr/sbin/program_reseller'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top