2

While configuring Unattended-Upgrades, the "/etc/apt/apt.conf.d/50unattended-upgrades" file contains the following:

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

I need to determine if the "02:00" references UTC time or local machine time? For that matter with the utilization of systemd does time settings in this config file matter when utilizing systemd "/lib/systemd/system/apt-daily.timer" settings?

1 Answers1

1

systemd defaults to parsing dates in the local timezone unless told otherwise. Excerpt of its time format documentation:

The timezone defaults to the current timezone if not specified explicitly. It may be given after a space, like above, in which case it can be: "UTC", an entry in the installed IANA timezone database ("CET", "Asia/Tokyo", &c.; complete list obtainable with "timedatectl list-timezones" (see timedatectl(1))), or "±05", "±0530", "±05:30", "Z".

So any date given to systemd that doesn't state a timezone will be in local timezone.

In addition, "now" means a reboot would be triggered at the end of unattended-upgrade upgrade operations which depends on apt-daily-upgrade.timer, not on apt-daily.timer which only does the update part of the operations:

$ systemctl cat apt-daily.service | grep ^ExecStart=
ExecStart=/usr/lib/apt/apt.systemd.daily update
$ systemctl cat apt-daily-upgrade.service | grep ^ExecStart=
ExecStart=/usr/lib/apt/apt.systemd.daily install

Typically by default the update operation runs twice a day, the upgrade/install operation once a night.

When a reboot is deemed necessary, unattended-upgrade will run the shutdown command as seen below since it's a python script:

$ grep /sbin/shutdown /usr/bin/unattended-upgrade
    cmd = ["/sbin/shutdown", "-r", when]

The shutdown command, provided by systemd or not, has its own syntax and rules for time format (for compatibility) and will not accept any arbitrary date, but only some limited formats, including now, hh:mm in the current local timezone, and a few other formats described in shutdown(8). unattended-upgrade will just copy the parameter provided in its configuration file, so this has to be valid for the shutdown command.

One should probably avoid a time that could be in the period during a timezone change if it's important in the setup to be sure when it will actually be done (eg: in the CET (Central European Time) timezone choosing 02:30 might possibly miss such reboot during the CET to CEST timezone transition where 02:00 will step to 03:00, depending on how shutdown and its specific systemd implementation behave, even though I'd be surprised this isn't accounted for). now is always safe in this regard.

A.B
  • 13,968