setting up cron with Raspbian

  • 1
  • Problem
  • Updated 4 years ago
Hi,

I have installed Rise Vision on some Raspberry Pi's and notice that some have been dropping the WiFi connection after booting up.  So I followed this advice and have created a script to check the network connection and reboot the Pi if it is not connected.

I have tried to get this script to run with cron but it is not being executed automatically.  I have commented out line 1230 rvp_update_crontab in the rvplayer file [to stop cron from being over-written].  Is there anything else I need to do?

My crontab entry is;- 

*/5 * * * * /usr/bin/sudo -H /usr/local/bin/checkwifi.sh >> /dev/null 2>&1
I have tried to add this as the default user, crontab -e, as well as sudo crontab -e.

Thanks for any help.
Photo of James Seymour

James Seymour

  • 160 Points 100 badge 2x thumb

Posted 4 years ago

  • 1
Photo of James Seymour

James Seymour

  • 160 Points 100 badge 2x thumb
To test this I re-created the script on an Ubuntu desktop and set up the crontab.  I had to use the root crontab [sudo crontab -e] to get it to work.

I have since re-configured another Pi and followed the same procedure as the Ubuntu desktop but still no luck getting it to work.

Does the RV player disable cron?
Photo of James Seymour

James Seymour

  • 160 Points 100 badge 2x thumb
I have now managed to figure this out, with the help from a work colleague.  It looks like the >> /dev/null was causing the cron job not to run.  So we changed this to /var/log/checkwifi.txt.

We also simplified the rest of the entry to this
*/5 * * * * sudo sh /usr/local/bin/checkwifi.sh >> /var/log/checkwifi.txt 2>&1
I understand from the original link that sending the output to the /dev/null prevents log files from increasing.  So I will run this for some time to collect the log file and then remove the link and only put it back if I need to troubleshoot.
Photo of Blake Freeman

Blake Freeman, Official Rep

  • 36,116 Points 20k badge 2x thumb
James,

Thanks for following up on this. This information will be useful to users that are interested in setting up their own Pi.