Running a Python script from crontab

Astley Le Jasper Astley.lejasper at
Wed Dec 3 11:28:35 CET 2008

Ok ... this is odd.

I tried gregory's suggestion of redirecting the stdout & stderr to a
text file. This worked. I could see all the logging information.
However, there was no error to see this time ... the application
worked completely without any problems.

I also then tried Jon's suggestion of attaching to the console ...
this also allowed me to see all the logging info as it went through.
Again, there were no problems as the application worked without any

Which suggests that it's the logging module or something with the
output streams.

Here is my logging setup in the primary module. It directs info to the
main console and also to a logging file.....

#Set up logging

log = logging.getLogger('scrape_manager')


my_filename = ss.compact_date() + '_' + time.strftime("%H%M")

 #Checks to see if the dir is there and creates it if not
log_file = 'logs/systemlog_' + my_filename + ".log"

console_h = logging.StreamHandler()

file_h = logging.FileHandler(log_file,'w')



console_fmt = logging.Formatter('%(levelname)s (%(threadName)-10s) %
(module)s %(message)s',)

file_fmt = logging.Formatter('%(asctime)s\t%(levelname)s\t(%




I also call this from an auxiliary module that is use my the primary

log = logging.getLogger('scrape_manager')

If I change the name of the logger in the auxilary module then I loose
all the loggiing information but the application works.

What am I doing wrong with the logging setup? I can't see how I would
change it.


More information about the Python-list mailing list