Set a scheduled time for software updates

Solution 1:

Edit the systemd timers for apt

There are three settings to change:

  1. /lib/systemd/system/apt-daily.timer

This provides your daily apt update, refreshing the package database. Change this section:

     [Timer]
     OnCalendar=*-*-* 6,18:00   // Try *-*-* 02:17 for nightly at 0217 (2:17 am)
     RandomizedDelaySec=12h     // Comment out this line (prepend with a '#') - you don't want random delay
     Persistent=true            // Keep this line
  1. /lib/systemd/system/apt-daily-upgrade.timer

This provides your daily Unattended Upgrades, installing security upgrades. The previous job MUST run first - calculating the upgrade requires reading the package database. Change this section:

     [Timer]
     OnCalendar=*-*-* 06:00     // Try *-*-* 03:17 for nightly at 0317 (3:17 am)
     RandomizedDelaySec=60m     // Comment out this line (prepend with a '#') - you don't want random delay
     Persistent=true            // Keep this line
  1. /etc/cron.daily/apt-compat

This job adds additional randomness to apt. The purpose is to avoid overloading mirrors by distributing job across time randomly. You accomplished the spirit of this goal by setting the other apt jobs to an unusual time (like 17 minutes past the hour).Change this section:

     # delay the job execution by a random amount of time
     random_sleep               // Comment out this line by adding a '#' in front.