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?
-
- Posts: 128
- Joined: Sun Dec 23, 2012 9:44 pm
Re: Python error logs
Is this what you need? Running this saves just the errors
and this saves both std output and errors
Code: Select all
$ python bad_scritpt 2> error_log.txt
Code: Select all
$ python bad_script &> full_log.txt
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d
-
- Posts: 128
- Joined: Sun Dec 23, 2012 9:44 pm
Re: Python error logs
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!
The problem with being new to Linux is that there is so much to remember - and forget!
Re: Python error logs
Thank you for the Boxing Day gift! Just what I was looking for!