10

I have setup automatic updates and it updates automatically. However, there are updates that require a restart and I know

Unattended-Upgrade::Automatic-Reboot "true";

will set it to reboot. But it reboots as soon as it updates. That could be at any time of the day, when my users are using my server. I want it to restart at a specific time, say 12:00 am that night. How do I do that?

2 Answers2

14

Have a look in /etc/apt/apt.conf.d/50unattended-upgrades. You want Unattended-Upgrade::Automatic-Reboot-Time:

// If automatic reboot is enabled and needed, reboot at the specific
// time instead of immediately
//  Default: "now"
//Unattended-Upgrade::Automatic-Reboot-Time "02:00";

It takes the time provided and uses it on /sbin/shutdown -r (source). This means you can use any time that shutdown accepts, in your set timezone.

2

You can disable automatic reboot by setting in your configuration file :

Unattended-Upgrade::Automatic-Reboot "false"

Reconfigure it :

dpkg-reconfigure -plow unattended-upgrades

Set a cron job to check the existence of reboot-required and reboot if needed:

crontab -e 

Then append the above :

0 0 * * * [ -f /var/run/reboot-required ] && reboot

Save it and it's done.

0 0 * * * means to be executed everyday at 12AM (midnight), change it as you wish.

redseven
  • 282