Still problems running script from cron 
Author Message
 Still problems running script from cron

Hi all,

I posted a while ago about a script that runs fine from the command
line, but hangs when run from cron.  I've made progress, but am not all
the way there yet.  Many people suggested helpful ways to redirect
stdout into files, but they had no effect.  I eventually managed to get
past the point where it was{*filter*} by changing:

os.system("%s -c %s -n %s -o %s %s" % (webalizer, conffile, self.server,
outputdir, self.currlog))


rv = os.system("%s -c %s -n %s -o %s %s" % (webalizer, conffile,
self.server, outputdir, self.currlog))

It then stopped{*filter*} there.  Now it hangs when my forks are supposed
to close, here:

children = 1

for server in servers:
  child = os.fork()
  if child == 0:            # Fork returns 0 in the child; if this is now
    break                   # a child, we want out of the loop.
    children = children+1   # Otherwise, we check to see if we're already
    if children > C:        # at the max number of processes; if not, we
      rv = os.wait()        # go to the top of the loop and fork another.
      children = children-1 # Otherwise, we wait until a fork closes.

The end of the child process looks like this:

# When both server stats and user stats are completed, we can finally get
# rid of the daily log and close the fork.


print ("+ %s  %s %s: No problems detected; closing fork."
       % (strftime(T, localtime(time())), procdate, id))

sys.exit()  # I've also tried using return here with no change

When run from cron, the message "No problems detected; closing fork."
prints as expected, but the child process never closes, according to ps.  
When run from the command line, it closes as expected.

Any idea why this might happen?



Mon, 14 Oct 2002 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Problem running Python script as cron job

2. expect: problems running script from CRON

3. Problems running expect script in the background/from cron

4. problem running expect script via cron

5. trouble running an expect script in cron versus command line

6. trouble running an Expect script from cron

7. Running expect scripts from cron..?

8. Running EXPECT script through cron

9. HELP: running tcl script as a cron job.

10. cannot run expect script under cron

11. script/cron problems

12. Problem running DBI under cron


Powered by phpBB® Forum Software