Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8621

Automation, sensing and robotics • Re: Problems with cron

$
0
0
Well. I also tried it without sudo. And when you say find the error...how do I do that? Everything looks right to me. Thats why I came here for help.
Thagrol's guide covers how to debug cron entries. I suggest you read it as it gives a lot of good advice.

The usual starting point is to add some logging to your entry (and remove that "&" on the end, it isn't needed in cron.
Change this

Code:

* * * * * /usr/bin/python3 /home/pi/gardenpi/test.py &
to this

Code:

* * * * * /usr/bin/python3 /home/pi/gardenpi/test.py >>/home/pi/gardenpi/test.log 2>&1
That will append any output to the file /home/pi/gardenpi/test.log which you can look at and see what is going wrong.

To explain what I did:
The ">>" means "redirect any standard output messages to append to the filename that follows this.
The "2>&1" means write any error output (2) messages to the same filename as standard messages (1). "2" is the file handle of the error output STDERR, "1" is the file handle of normal output STDOUT (the default). "0" is the file handle of normal input STDIN.

Statistics: Posted by rpdom — Fri May 16, 2025 7:02 am



Viewing all articles
Browse latest Browse all 8621

Trending Articles