Shorten boot time "apt-daily.service"

I was getting a long boot up time of about 2 minutes.

I ran systemd-analyze blame. (the blame part is cute.)

You should not see apt-daily-service in the listing.

I found a fix that shortened that time by 30 seconds.

This was the tip that worked.

This is Debian bug #844453. apt-daily.service shouldn't be run during boot, but only some time afterward.

As a workaround, do sudo systemctl edit apt-daily.timer and paste the following text into the editor window:

apt-daily timer configuration override

[Timer]
OnBootSec=15min
OnUnitActiveSec=1d
AccuracySec=1h
RandomizedDelaySec=30min

This changes the "timer" that triggers apt-daily.service to run at a random time between 15 min and 45 min after boot, and once a day thereafter. See the systemd.timer manpage for additional (not very well written, alas) explanation of what this means.

3 Likes

Thanks, that saves some boot time indeed.

Thanks for the tip, had already noticed the apt-daily.service running at boot on one of my laptops. This helped.

You are most welcome.

I like to see what terminal commands are supposed to do so I investigated. This command creates a directory called apt-daily.timer.d under /etc/systemd/system/ with (if you know joe commands) a file named override.conf with -

[Timer]
OnBootSec=15min
OnUnitActiveSec=1d
AccuracySec=1h
RandomizedDelaySec=30min

this text in it. No particular help that I can see if you use an SSD drive but quite useful otherwise. Thanks for the tip and for posting where you got it.

1 Like

Which will change the timing of unit file /lib/systemd/system/apt-daily.service
which will exec Python script /usr/lib/apt/apt.systemd.daily
which has a configuration file /etc/apt/apt.conf.d/10periodic

which in my system contains:

APT::Periodic::Update-Package-Lists “1”;
APT::Periodic::Download-Upgradeable-Packages “0”;
APT::Periodic::AutocleanInterval “0”;

which means (the Update-Package-Lists bit) “apt-get update” will be run automagically every day.

So: if apt-daily.service runs at boot before network connection is established, it will have to wait for the connection before it can “apt-get update”.

Which, of course, will increase the boot time (“slow down boot”), no matter how fast the hard disk is.

5 Likes

Your full explanation is great! Thanks for taking the time to write this out samuvuo.