cron not working

Hello,
due to the fact that my Raspberry Pi2 with Pi-hole crashes every 1 or 2 weeks I want to add a cron job to reboot it once a week, but when I enter
sudo cron
the following error message appears:

cron: can't lock /var/run/crond.pid, otherpid may be 263: Resource temporarily unavailable

Any advice is appreciated...

explained here, with example(s)

more info / examples? duckduck go for "linux schedule weekly reboot".

Assuming your RasPi is running some version of Raspbian, the crontab command jpgpi250 suggested is the simplest option for a weekly reboot.

  1. Run sudo crontab -e to open a text editor with the cron file.
  2. Type 0 3 * * 0 reboot on its own line in file
  3. Save the file

Basically that line on step two tells your Pi to "Execute reboot command at 3am on every Sunday of the week". I just chose 3am on a Sunday just as a personal preference. If you would rather it reboot every week since you last turned it on instead of a specific time each week, then change the step two line to @weekly reboot.

A better solution would be to figure out why it's crashing and fix that problem. Crashing is not an expected outcome in a Linux system - they typically can run for years with no problems.

Thanks to all for your replies, and of course I want to find out the reason for the crashes, but I think that this would be too time-consuming at the moment, so a scheduled reboot keeps me from complaints about missing internet here until I investigate.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.