chorlton2080
Posts: 128
Joined: Sun Dec 23, 2012 9:44 pm

Python error logs

Sun Dec 15, 2013 9:41 pm

Hello folks

I run my Raspberries headless and my SSH sessions are usually brief. Too brief to encounter the intermittent errors that seem to stop my Python scripts: I'm therefore in the dark as to the root causes sometimes. I think, though I'm not sure, it may be due to file access conflicts.

The scripts are initiated using cron at boot and typically function for a few hours before failing: because the RPi's are located in a remote location I'm unable to keep remote connection alive for that period to watch the execution of the script and the error unfold (and thus observe the error message).

Does a log file exist for Python runtime errors or can such be enabled in my scripts?

User avatar
paddyg
Posts: 2612
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: Python error logs

Sun Dec 15, 2013 11:51 pm

Is this what you need? Running this saves just the errors

Code: Select all

$ python bad_scritpt 2> error_log.txt
and this saves both std output and errors

Code: Select all

$ python bad_script &> full_log.txt
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

chorlton2080
Posts: 128
Joined: Sun Dec 23, 2012 9:44 pm

Re: Python error logs

Mon Dec 16, 2013 12:31 am

Excellent! Haven't tried it but I've seen something similar before with bash so I'm sure it'll work.

The problem with being new to Linux is that there is so much to remember - and forget!

k6rtm
Posts: 16
Joined: Thu Sep 27, 2012 8:50 pm

Re: Python error logs

Fri Dec 27, 2013 12:15 am

Thank you for the Boxing Day gift! Just what I was looking for!

Return to “Python”