Re: Running a Python script from crontab

2008-12-04 Thread Philip Semanchuk
On Dec 4, 2008, at 4:21 AM, Astley Le Jasper wrote: On Dec 4, 12:34 am, Lawrence D'Oliveiro <[EMAIL PROTECTED] central.gen.new_zealand> wrote: In message <[EMAIL PROTECTED]>, Philip Semanchuk wrote: In my experience, the environment in which a cron job runs is different from the environmen

Re: Running a Python script from crontab

2008-12-04 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Astley Le Jasper wrote: > On Dec 4, 12:34 am, Lawrence D'Oliveiro <[EMAIL PROTECTED] > central.gen.new_zealand> wrote: >> >> For example, here are some headers from a recent run of the >> maildir backup task I have scheduled twice a day: >> >> Subject: Cron <[EMAIL

Re: Running a Python script from crontab

2008-12-04 Thread Astley Le Jasper
On Dec 4, 12:34 am, Lawrence D'Oliveiro <[EMAIL PROTECTED] central.gen.new_zealand> wrote: > In message <[EMAIL PROTECTED]>, Philip > > Semanchuk wrote: > > In my experience, the environment in which a cron job runs is > > different from the environment in which some command line scripts run... > >

Re: Running a Python script from crontab

2008-12-03 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Philip Semanchuk wrote: > In my experience, the environment in which a cron job runs is > different from the environment in which some command line scripts run... Which is true, but again, cron should report the environment in the mail message. For example, here ar

Re: Running a Python script from crontab

2008-12-03 Thread Philip Semanchuk
On Dec 3, 2008, at 3:06 PM, Astley Le Jasper wrote: On 3 Dec, 19:49, Philip Semanchuk <[EMAIL PROTECTED]> wrote: On Dec 3, 2008, at 1:33 PM, Astley Le Jasper wrote: On 3 Dec, 16:41, Philip Semanchuk <[EMAIL PROTECTED]> wrote: On Dec 3, 2008, at 10:29 AM, Astley Le Jasper wrote: I've incl

Re: Running a Python script from crontab

2008-12-03 Thread Astley Le Jasper
On 3 Dec, 19:49, Philip Semanchuk <[EMAIL PROTECTED]> wrote: > On Dec 3, 2008, at 1:33 PM, Astley Le Jasper wrote: > > > > > On 3 Dec, 16:41, Philip Semanchuk <[EMAIL PROTECTED]> wrote: > >> On Dec 3, 2008, at 10:29 AM, Astley Le Jasper wrote: > > >>> I've included a switch to include or exclude th

Re: Running a Python script from crontab

2008-12-03 Thread Philip Semanchuk
On Dec 3, 2008, at 1:33 PM, Astley Le Jasper wrote: On 3 Dec, 16:41, Philip Semanchuk <[EMAIL PROTECTED]> wrote: On Dec 3, 2008, at 10:29 AM, Astley Le Jasper wrote: I've included a switch to include or exclude theloggingto console. Whenloggingonly to file, the script runs fine. Of course

Re: Running a Python script from crontab

2008-12-03 Thread Astley Le Jasper
On 3 Dec, 16:41, Philip Semanchuk <[EMAIL PROTECTED]> wrote: > On Dec 3, 2008, at 10:29 AM, Astley Le Jasper wrote: > > > I've included a switch to include or exclude theloggingto console. > > Whenloggingonly to file, the script runs fine. > > > Of course, I still don't understand whyduallogging, a

Re: Running a Python script from crontab

2008-12-03 Thread Philip Semanchuk
On Dec 3, 2008, at 10:29 AM, Astley Le Jasper wrote: I've included a switch to include or exclude the logging to console. When logging only to file, the script runs fine. Of course, I still don't understand why dual logging, and specifically to the console, causes a problem and if anyone has a

Re: Running a Python script from crontab

2008-12-03 Thread Astley Le Jasper
I've included a switch to include or exclude the logging to console. When logging only to file, the script runs fine. Of course, I still don't understand why dual logging, and specifically to the console, causes a problem and if anyone has any comments about the dual output logging code above then

Re: Running a Python script from crontab

2008-12-03 Thread Lawrence D'Oliveiro
In message <[EMAIL PROTECTED]>, Astley Le Jasper wrote: > The trouble is that obviously I get no console when using crontab so > can't see any traceback. Cron normally sends you mail if a cron task generated any output (this should include error messages). -- http://mail.python.org/mailman/listin

Re: Running a Python script from crontab

2008-12-03 Thread Astley Le Jasper
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

Re: Running a Python script from crontab

2008-12-02 Thread Jon Redgrave
On Dec 2, 2:35 pm, Astley Le Jasper <[EMAIL PROTECTED]> wrote: ... Try using the "screen" utility - change the line in your crontab: cd /home/myusername/src && python myscript.py to cd /home/myusername/src && screen -dmS mypthon python -i myscript.py then once cron has started your program attach

Re: Running a Python script from crontab

2008-12-02 Thread David
Astley Le Jasper wrote: >> my crontab is: 30 15 * * * cd /home/myusername/src && python myscript.py I create a file runmyscript.sh and put it in /usr/bin #!/bin/bash cd /home/myusername.src python /path/to/myscript then chmod a+x /usr/bin/runmyscript.sh test it ./runmyscript add it to the

Re: Running a Python script from crontab

2008-12-02 Thread gregory . j . baker
Try using the following at the begining of your Python program: import sys sys.stdout = open("out.txt","w") sys.stderr = open("err.txt","w") Then whatever would normally go to stdout or stderr goes to text files instead. You will see everything that happened. -- http://mail.python.org/mailman/

Re: Running a Python script from crontab

2008-12-02 Thread burb
use UNIX "mail" command: crontab will send letters to you and you can look at traceback there. -- http://mail.python.org/mailman/listinfo/python-list

Re: Running a Python script from crontab

2008-12-02 Thread Astley Le Jasper
James ... thanks for the suggestion. I have done this and the error logging usually catches all my errors and logs them. I wondered if logging itself was failing! Philip ... thanks also. I did wonder about making the everything explicit. I've seen that mentioned elsewhere. Writing out the stdout &

Re: Running a Python script from crontab

2008-12-02 Thread Philip Semanchuk
On Dec 2, 2008, at 9:35 AM, Astley Le Jasper wrote: I need help ... I've been looking at this every evening for over a week now. I'd like to see my kids again! I have script that runs fine in the terminal but when I try to run it in a crontab for either myself or root, it bails out. The troub

Re: Running a Python script from crontab

2008-12-02 Thread James Mills
Put your main function in a big try, except. Catch any and all errors and log them. Example: def main(): try: do_something() except Exception, error: log("ERROR: %s" % error) log(format_exc()) Hope this helps. cheers James On Wed, Dec 3, 2008 at 12:35 AM, Astley Le Jaspe

Running a Python script from crontab

2008-12-02 Thread Astley Le Jasper
I need help ... I've been looking at this every evening for over a week now. I'd like to see my kids again! I have script that runs fine in the terminal but when I try to run it in a crontab for either myself or root, it bails out. The trouble is that obviously I get no console when using crontab