how can I schedule a reboot in Linux?
I'm new in Linux and I want to schedule a reboot at midnight. How should I do it?
Edits:
I'm sorry I didn't put the complete details. I want a reboot every 3rd Saturday of the month at 23:30.
I don't know what's wrong but I cannot find crontab. What I have is
cron.d
;cron.daily
;cron.weekly
;cron.monthly
;
I'm sorry for the noob question. Pls help me. Thanks.
Type shutdown -r 0:00
and it will reboot at midnight.
If you want to reboot each night, add a cron entry using crontab -e as root to run shutdown -r each midnight
@midnight shutdown -r now
Using crontab
.
http://en.wikipedia.org/wiki/Crontab
Adding this entry to /etc/crontab should do:
0 0 * * * /sbin/shutdown -r now
Another option is the at command, available on many Linux distributions. See the man page for more info, but the general syntax for your purpose would be:
echo "reboot" | at 0000 jun 27
To quote the OS X man page:
at - executes commands at a specified time
Sound like what we're talking about. ;)
As far as I know, you cannot use cron to schedule tasks for "last Friday of each month" or "third Thursday in each month". What you can do, however ugly it seems, is to have a script run every Saturday at 23:30 and then have this script determine if this particular Saturday is the third Saturday of the week (can be done using date and maybe cal commands).
I hope this helps. I have not found an elagant solution to this problem. I found this thread, because I was searching for a solution for the same problem.