I want to run a Java / pi4j Task (Script ControlGpioExample) periodically using crontab on my Raspberry PI.
This code works well on the Terminal:
sudo java -classpath .:classes:/opt/pi4j/lib/'*' ControlGpioExample
In Crontab I added the following line (in this case at 19:58):
00 20 * * * sudo java -classpath .:classes:/opt/pi4j/lib/'*'
ControlGpioExample >/dev/null/ 2>&1
However, this job did not start at 20:00 nor did I get any further information using ...
grep CRON /var/log/syslog
Other stackoverflow users had similar problems with Cronetab not running Java Code, so I also tried this:
00 20 * * * sudo java -classpath .:classes:/opt/pi4j/lib/'*'
ControlGpioExample > /var/log/javacron.log 2> /var/log/javacron-err.log
>/dev/null/ 2>&1
Again, Crontab shows only that the code had been executed but no error message!
Problems of other users suggest that perhaps something with my path or environment variables seems to be incorrect? How I can I find this out, what else do I have to set to run this script? Please help, I already try to fix this problem for 2 days!
Thank you!
> /dev/null/
seems wrong to me, because of the extra /
at the end.
What about this?
00 20 * * * sudo java -classpath .:classes:/opt/pi4j/lib/'*' ControlGpioExample >/var/log/javacron.log 2>/var/log/javacron-err.log
Or that:
00 20 * * * sudo java -classpath .:classes:/opt/pi4j/lib/'*' ControlGpioExample >/dev/null 2>&1