Python and Cron
gslindstrom at gmail.com
Fri Sep 7 21:09:06 CEST 2007
> Can you post the Python script?
Not the whole thing; it's quite long. But here's the relevant parts. We're
using the ado database interface into postgres (that's what the
results.EOFis all about)
output_file = file(output_path, 'w') # output_path =
while not results.EOF:
row = results.GetRowAssoc(upper=0)
debug('Total Bytes Written: %d' % total_bytes)
new_path = None
if total_bytes > 0: new_path = output_path.replace('/work/', '/')
else: new_path = output_path.replace('/work/',
debug('Original Path [%s]'%output_path) # new_path =
debug(' New Path [%s]'%new_path) # new_path =
The original code looked like this (worked from command line, failed with
But since that didn't work and I could create a new file, I tried this as a
output_file = file(new_path, 'w')
for line in file(output_path):
The interesting/infuriating thing is that the second method also fails; that
is, the file is not moved to the data directory or the "empty"
directory...it remains in the "work" directory after the cron job
completes. If I run the same routine from the command like (after su'ing to
the edith user) it runs and moves the file to the appropriate directory.
I am going to see if we can get the email routing set up (we run over 100
cron jobs daily so I'm not sure I want it on too long) to see if it will
tell me anything.
Thanks for your time and effort
What's the name of the original file, and what are you trying to rename
> it to? I'm wondering if you are deriving the new name from something,
> and that thing is failing from within the cronjob for some reason.
> Perhaps the new name contains a complete path in one of the cases but
> not in the other...
> Edith should be getting email (if email routing is set up correctly) if
> the job is failing or producing output. Specifically, perhaps she's
> getting Python tracebacks and not telling you... :)
> pkm ~ http://paulmcnett.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list