Hey all I have a problem with a program
You see, I have a python script made in Python 2.2 that runs every 15 minutes on Linux Red Hat 9.0 This program (which code is attached below) named levantamuertos.py (spanish for death weakener) has to check in a database if the pids stored are running (note that it will be more than one pid) and if they are not it has to start again the process and it will store the new pid on the database The problem is that when I call it it runs and weaks all dead process but when it dies, he takes all his sons with him. How can I make that the cotascamon.py keep running although levantamuertos.py die? Thanks in advanced and here is the code Alberto ################## ### levantamuertos.py ### ################## import os import sys import MySQLdb import time class conexion(object): def __init__(self): self.db = MySQLdb.connect(host="localhost", user="administrador", passwd="123456",db="seguridad") def consulta(self,query,args=None): try: self.cursor=self.db.cursor() self.sql=self.cursor.execute(query,args) except: self.cerrar() else: self.cerrar() def cerrar(self): self.db.close() query="SELECT PID,user,cam,ruta from proceso where user='DMALAKIAN'" cur=conexion() cur.consulta(query) res=cur.cursor.fetchall() if len(res)>0: for elem in res: pi=elem[0] ps_command = 'ps -p %s' % pi pidchk = os.popen(ps_command).readlines() count = 0 for line in pidchk: count +=1 if count > 1: print "Encontre el proceso" else: query="update proceso set PID=%s where user='DMALAKIAN'" p=os.getpid() args=(p) cur=conexion() cur.consulta(query,args) query="SELECT PID,user,cam,ruta from proceso where user <> 'DMALAKIAN'" cur=conexion() cur.consulta(query) res=cur.cursor.fetchall() if len(res)>0: for elem in res: pid=elem[0] user=elem[1] cam=elem[2] ruta=str(elem[3]) ps_command = 'ps -p %s' % pid pidchk = os.popen(ps_command).readlines() count = 0 for line in pidchk: count +=1 if count > 1: pass else: os.system("python2.2 /root/cotascamon.py "+str(ruta[19:len(ruta)])+" "+user+" "+str(cam)) else: pass else: query="insert into proceso values('DMALAKIAN',0,%s,'NO HAY RUTA PARA ESTE USUARIO')" p=os.getpid() args=(p) cur=conexion() cur.consulta(query,args) query="SELECT PID,user,cam,ruta from proceso where user <> 'DMALAKIAN'" cur=conexion() cur.consulta(query) res=cur.cursor.fetchall() if len(res)>0: for elem in res: pid=elem[0] user=elem[1] cam=elem[2] ruta=str(elem[3]) ps_command = 'ps -p %s' % pid pidchk = os.popen(ps_command).readlines() count = 0 for line in pidchk: count +=1 if count > 1: pass else: os.system("python2.2 /root/cotascamon.py "+str(ruta[19:len(ruta)])+" "+user+" "+str(cam)) else: pass _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor