I'm new in Linux and I want to schedule its reboot in midnight. How should I do it?
-I'm sorry I didn.y put the complete details. I want a reboot every 3rd Saturday of the month at 23:30
-i dont know what's wrong but i cannot find the crontab..? what i have is the 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 nowTobu : A time argument is mandatory, you can use `now`.radius : No ... if he want a one time command and want to type the command now, he should add the time !Dennis Williamson : @No, it needs a time argument such as `now` in the crontab line.radius : Oups yes sorry, I misread Tobu comment and think he tells 0:00 was useless in the first command... I edited to correct (and Massimo answers too)From radius -
Using
crontab.http://en.wikipedia.org/wiki/Crontab
Adding this entry to /etc/crontab should do:
0 0 * * * /sbin/shutdown -r nowDennis Williamson : `shutdown` needs a time argument such as `now`cstamas : This will do the reboot every night. I am not sure if this is what he wants.Chris S : The original question made it sound like he wanted it rebooted every night. He actually wants it rebooted every 3rd Saturday, which would still be easiest with a crontabklauriens : i dont know what's wrong but i cannot find the crontab..? what i have is the cron.d;cron.daily; cron.weekly; cron.monthly; I'm sorry for the noob question.Pls help me. thanksMassimo : It depends on the distribution you're using, but usually you should find a file called "crontab" in your system's /etc directory. You should also be able to examine the current crontab using the command "crontab -l", and to edit it using "crontab -e".From Massimo -
The real question is why you'd want to be doing this regularly, do you have a leaky application or something? If you're scheduling regular reboots to solve a problem then you've probably got a bigger problem...
Matt Simmons : I'm not voting down, because it's sort of a policy decision (and I think nightly reboots are a bit excessive), but regularly scheduling reboots across an infrastructure are a decent way of ensuring that machines have up to date kernels and all services running are patched. I've heard a 3 month uptime limit as being a good middle ground.intuited : If this was a comment on the question, rather than an answer, I would upvote it. Actually I would change my mind, because the question was ambiguous about whether this was a one-time or regular thing. :)symcbean : @Matt Simmons: so you don't keep track of the patches you apply and reboot when its required?Matt Simmons : @symcbean - Sure, but if you reboot everything at the same time, then...well, you lose service availability AND it's chaos. I can see advancing the schedule because of a critical vulnerability, but every small kernel upgrade doesn't mean "install-it-now-or-dire-circumstances-ensue".symcbean : @Matt Simmons: If you can't reboot a server without losing service, then you've got architecture problems you really should fix.Matt Simmons : symcbean: Yes, however if you do updates and reboots across the board, all at once, you lose service because the other members of the service group go down too. I think we're arguing about the same thing ;-)From JamesHannah -
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:
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. ;)
From Zayne S Halsall
0 comments:
Post a Comment