I'd like to schedule a shutdown every day at a specific time for my system. I found this post that addresses this, but I can't find rc.local I looked around and it seems like this file doesn't exist on Ubuntu 20.04 I was wondering what the best way to solve this problem is? Should I create this file or is there a file that "substitutes" it?
PS: currently the answers to my question mention cron
. However, I found the accepted answer to this post that recommends not using cron
for shutdown. I was wondering if someone could elaborate on this option too and why it is not / or is a good option
With a quick search, I hopefully found the answer you're looking for
Automatic shutdown at specified times?
From: Automatic shutdown at specified times?
Reply if it worked! Good luck!
To run sample.sh twice a day. say 5am and 5pm
0 5,17 * * * shutdown.sh
Or, alternativly you can use:
and enter 0 0 * * 0 root /sbin/shutdown -r now
For example
References:
https://unix.stackexchange.com/questions/208205/how-to-schedule-shutdown-every-day
https://www.unix.com/red-hat/173983-cronjob-command-shutdown.html
https://www.tutorialspoint.com/unix_commands/crontab.htm
https://help.ubuntu.com/community/CronHowto
https://www.ryadel.com/en/linux-auto-reboot-shutdown-cron-job-crontab-task-scheduler/
https://linuxize.com/post/cron-jobs-every-5-10-15-minutes/
shutdown 5:30pm every day
recurring scheduled shutdown
crontab -e
, then enter your command at the bottom of the text lines.cron
command syntax, it can be viewed atman cron
.