Schedule your Pi or other Linux machine to reboot and run a script on boot with crontab

Simple concept. We want to ensure that our Pi is available and reliable.
It is inevitable that networks get hickups, or the Pi runs out of memory requiring restart at a regular interval.

For exaomple if you want to run a bash file after a reboot every 6am and 6pm, you would setup a crontab as follows:
sudo crontab -e
#M H D M DW CMD
0 6,18 * * * /sbin/shutdown -r
@reboot cd /home/pi && sh notify.sh

You could also run a python 3 program as a root every first day of each month, as such:
sudo crontab -e
#M H D M DW CMD
0 0 1 * * root /usr/bin/python3 /home/pi/hello.py

The linux crontab format:
MIN HOUR DOM MON DOW CMD
MIN minute 0-59
HOUR hour 0-23
DOM day of month 1-31
MON month 1-12
DOW day of week 0-6
CMD command Command script to be executed

Good luck!

(Visited 560 times, 1 visits today)