I have a python script running by cron. For what ever reason, it is not running. I am wondering if there is anywhere that error messages are sent? Script runs fine by itself. If I run a simple script with crontab, that just writes to a file that works also.
My crontab is:
*/15 * * * * python ./home/pi/foo/bar.pyw
-
1Ok, I figured out the issue with my script. I was calling modules which were in the same directory as the bar.pyw script. I changed the working directory with os.chdir("some location"). I still however would like to know where the error messages go for crontabsRichard– Richard2012年11月26日 19:46:03 +00:00Commented Nov 26, 2012 at 19:46
2 Answers 2
By default, the logging for the cron
daemon is not enabled in Debian (I assume it is the system you are using). To enable it, please open the file /etc/rsyslog.conf
via
$ vi /etc/rsyslog.conf
and uncomment the line
# cron.* /var/log/cron.log
After that, you need to restart rsyslog
via
$ /etc/init.d/rsyslog restart
and you will find the cron logs in /var/log/cron.log
-
1Alf: Thank you for your reply. I have now implemented cron logging and have alter the command in my crontab to [Code] */3 * * * * /usr/bin/sudo -H /home/pi/ahbc [/code] The sudo -H is something I found on the web which I am told works. I don't understand just what the -H is there for. I have been given to understand that if one does not include the uservin a crontab command line that command will run using the user/owner of crontab. Therefore as my crontab is user pi crontab the contained commands will run for pi.Bex– Bex2015年01月12日 07:42:36 +00:00Commented Jan 12, 2015 at 7:42
-
the link is broken now :(Michael– Michael2015年06月08日 20:27:48 +00:00Commented Jun 8, 2015 at 20:27
-
@Michael The explanation here should be enough to achieve logging. Do you need something else?Morgan Courbet– Morgan Courbet2015年06月08日 21:43:33 +00:00Commented Jun 8, 2015 at 21:43
-
2@ElanHasson Anything that generates extra writes to the SD card and is a low priority is generally disabled on the rPi.SiKing– SiKing2016年12月02日 16:39:43 +00:00Commented Dec 2, 2016 at 16:39
-
I've just posted an edit request for the link, it looks like the source site just changed it's setup a bit.Kioshiki– Kioshiki2017年01月22日 14:53:27 +00:00Commented Jan 22, 2017 at 14:53
Crontab has several parameters (in additional to time execution lines) For example:
MAILTO="[email protected]"
SHELL="/bin/bash"