After two days of attempting to get Cron to execute tasks (in this case shell scripts) on a Raspberry PI, I finally got it working.
I must have read at least three dozen sites and all my Raspberry Pi books in my attempts, nothing work..
Here are some of the suggestions I found.
This one states it will edit the users cron file:
pi@raspberry ~ $ crontab -e
This one states it will display all the users schedule cron tasks:
pi@raspberry ~ $ crontab -l
I did find these useful:
pi@raspberry ~ $ /etc/init.d/cron stop
pi@raspberry ~ $ /etc/init.d/cron start
pi@raspberry ~ $ /etc/init.d/cron restart
But none triggered my script to run, then in my notes, from a past project I found:
pi@raspberry ~ $ sudo nano /etc/crontab
This allowed me to edit the system cron task list..
———————————————–
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don’t have to run the `crontab’
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts –report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts –repo$
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts –repo$
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts –repo$
10 * * * * pi cd /home/pi && ./jabberfix.sh
#
———————————————–
The last task, which runs at 10 minutes after the hour, for user pi, fixes my jabber connection.
Honestly, I have no clue what the other tasks are doing. More research! But I am very happy I now know how to add my own tasks to cron.
Enjoy
~David