Hello. Do you like my script to restart Zope? I don't.
I followed instructions in the Zope archive to write a
restart script for Zope. It works if I run it from the
command line but if I put it in a cron job, it hangs
and does not start properly. Can you help me? 

THANK YOU.

Heather

#!/usr/bin/python

import os, string

# My Zope is installed in /usr/zope 
# So the commands to stop and start it are,
stopcmd = "/usr/zope/stop"
startcmd = "/usr/zope/start &"

# Command to check Zope processes running,
cmd = "ps aux | grep zope" 

# Find the Zope PIDs that are actually running,
readstdin = os.popen(cmd).readlines()
pids = []
for eachline in readstdin :
    words = string.split(eachline)
    if len(words) > 2 : 
        pids.append(words[1])
        pids.append(string.split(eachline)[1])

# Find the PIDs that should be running,
pidsfile = "/usr/zope/var/Z2.pid"
f = open(pidsfile, 'r')
data = f.read()
f.close()
runningpids = 0
zopepids = string.split(data)
for eachpid in zopepids :
    if eachpid in pids : 
        runningpids = runningpids + 1

if runningpids != 2 : 
    os.popen(stopcmd)
    os.popen(startcmd)

__________________________________________________
Do You Yahoo!?
Yahoo! Messenger - Talk while you surf!  It's FREE.
http://im.yahoo.com/

_______________________________________________
Zope maillist  -  [EMAIL PROTECTED]
http://lists.zope.org/mailman/listinfo/zope
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-announce
 http://lists.zope.org/mailman/listinfo/zope-dev )

Reply via email to