Recommended way to auto-reboot CentOS once per week?
I need it to be up in general, but a weekly late-night reboot won't cause any major business problems.
In order to keep the system up to date I put this in root's crontab…
6 3 * * * /usr/bin/yum update -y 2>&1 > /home/my_account/log/yum_update.log
So I'm running yum update -y daily there.
Sometimes an update requires a restart.
So to deal with that, I'd like to somehow set up this machine to reboot itself once per week.
What's a good way to do that?
(I considered adding a weekly cron job to run shutdown -r now, but I'm not sure if that would work well with a VPS machine.)
I understand many sysadmins would not consider this whole setup in general to be acceptable for a production system.
But I'm just hosting some personal apps and utils here. If an update goes awry and I need to restore from backup, it's ok.
My goal here is to keep this system patched and secure without costing too much of my time and attention which I need for other priorities that actually are critical.
In case it matters, I'll be running Apache, MySQL, and sshd.
Any help or advice would be greatly appreciated.
Thanks!
12 Replies
0 1 * * 1 /sbin/shutdown -r +5
Can't really see the advantage of this, if you're going to update daily (nightly) you probably want to reboot nightly too - otherwise a update that requires a reboot done on monday, will have to wait until sunday to get rebooted (plus stacking updates that require a reboot isn't a good idea either).
Of course willy nilly updates and reboots are just oh such a bad bad idea, but you already know that.
Yeah, it isn't the greatest. Maybe I'll try to work out a better strategy, like manually once a week.
Realistically though, given the risk level and time constraints involved, this may be the least bad option for this particular host.
What does the "+5" option do?
@sweh:
Will that work on linode, or will it result in a shutdown until Lassie detects the outage and schedules a boot from the management infrastructure?
It'll result in a shutdown until Lassie boots back up.
@obs:
@sweh:Will that work on linode, or will it result in a shutdown until Lassie detects the outage and schedules a boot from the management infrastructure?
It'll result in a shutdown until Lassie boots back up.
Yeah that's what the log is showing.
I thought maybe the usual shutdown command wouldn't work on Linode, which is why I originally asked.
It there a preferable way to configure the reboot?
So "why" doesn't this work on a Linode VPS when it works on a physical server?
@Eethy:
It there a preferable way to configure the reboot?
Use the API?https://www.linode.com/api/linode/linode.reboot
@vonskippy:
So "why" doesn't this work on a Linode VPS when it works on a physical server?
I'm guessing it's something to do with how Xen is configured, but I dunno what. It does seem odd!
ssh -t [manager-username]@lish-[location].linode.com [linode-name] reboot
-Chris
Thanks for the help, guys.