I live in a remote area, and my internet is satellite based. The data is expensive, and limited, however overnight it isn't metered, and data moves faster. How can I schedule software updater to perform updates at night? I've seen many similar questions to mine, but no answers. Is there a simple to moderately tech savvy script one could write?
1 Answer
Edit the systemd timers for apt
There are three settings to change:
/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
/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
/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.