[Solved] Running Cron job at reboot on Raspberry Pi in Debian(Wheezy) and Raspbian.
Hello Pi users,
After investing much time then expected to run a cron job at reboot in Rapbian. finally I am able to run the cron job at startup and able to execute the necessary commands at start-up.
It is quite Obvious that @reboot will run the cron job at start up but in Raspbian and Debian (wheezy) it is not the case.
@reboot does not works as expected and it is a bug in debaian you can read it here https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=635473
So here are the steps to for running cron job at reboot :-
-
log in to your pi using ssh
-
switch to root user using sudo bash
-
run the command crontab -e
-
put your command as @reboot bash /path/to/file/run.sh save it and get back on terminal
-
then start cron service by running /etc/init.d/cron start
-
then one additional step is to edit the /etc/rc.local file and add the following line in /etc/init.d/cron/start be sure that it should before exit 0.
-
now reboot your system by command reboot
and now your cron job is started you can check it by command ps aux | grep cron
also you can check the log tail /var/log/syslog.
Posted on 09/03/2014, in Technical and tagged cron, Debian, Raspberry Pi, Raspbian, reboot, start-up. Bookmark the permalink. 1 Comment.
Hi, Thanks for the instruction. I am using RPi3/Raspbian and my cron is already automatically started because I have a job there that runs every hour and I don’t need to start the cron manually. Do I still need to put /etc/init.d/cron/start in /etc/rc.local file? Thanks for your help.
LikeLike