Recommended way to auto-reboot CentOS once per week?

I have a CentOS 6 machine that's hosting some non-critical Web applications.

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.

My main question –>

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

As root, add to your cron job

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.

Thanks for the response, vonskippy.

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?

Oh, I see. It gives logged in users (i.e., me) a five-minute warning. Cool :)

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?

@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?

Excepting kernel updates, no update on Linux should require a reboot; the files are overwritten in-place and then the service is restarted…

My bad for not trying it before posting.

:oops:

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!

Key Lish with your ssh key, and then issue the reboot via Lish-via-ssh:

https://library.linode.com/using-lish-t … public-key">https://library.linode.com/using-lish-the-linode-shell#sph_adding-your-public-key

https://library.linode.com/using-lish-t … ish-tricks">https://library.linode.com/using-lish-the-linode-shell#sph_advanced-lish-tricks

ssh -t [manager-username]@lish-[location].linode.com [linode-name] reboot

-Chris

Excellent!

Thanks for the help, guys.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct