So because one of my VMs was acting up (due to a lot of transcoding on my media server) when not rebooting for a long period, I had to look for a cronjob format that would help with this issue.
I’d use cron (should already be installed):
sudo crontab -e
ShellSessionThe first time you might have to choose your preferred editor (like nano)
Insert a line like –
0 4 * * * /sbin/shutdown -r +5
ShellScriptat the bottom. Explanation:
m h dom mon dow command
minute hour dayOfMonth Month dayOfWeek commandToRun
ShellScriptso the 1st line would reboot your system every day at 4:05am. (4:00am + 5 minutes)
Ctrl+X, Y, Enter should get you out of crontab (if using nano)
Note: you might have to run crontab -e
as root, because shutdown needs root. crontab -e
opens a file in /tmp instead of the actual crontab so that it can check your new crontab for errors. If there are no errors, then your actual crontab will be updated.