Checking systemd unit health with systemctl --failed or reviewing system logs on Ubuntu Linux can reveal the recurring failure alert: [FAILED] Failed to start Daily apt download activities, pointing to the unit apt-daily.service. In Ubuntu, apt-daily.service runs automatically via systemd timers to refresh package repositories and download unattended security updates in the background. When this service fails, understanding the underlying repository or lock contention ensures seamless automated security patching.
Inspect Service Status and Specific Execution Errors
To determine the exact reason apt-daily.service exited with a failure code, examine the systemd status log in a terminal:
- Open a terminal and check service status:
systemctl status apt-daily.service - View recent journal entries for the failed unit:
journalctl -u apt-daily.service -b 0 - Common failure triggers include:
Could not get lock /var/lib/apt/lists/lock: Occurs when another package manager (such as unattended-upgrades, software-updater, or a manual apt command) holds an exclusive database lock.Failed to fetch ... 404 Not Found: Occurs when a third-party PPA repository is deprecated or unreachable.Certificate verification failed: Points to expired SSL certificates or system clock drift.
Clear Stale APT Lock Files
An unexpected shutdown or crash during an earlier update can leave orphaned lock files in the filesystem, preventing systemd from initialising APT queues:
- Verify that no other apt or dpkg processes are actively running:
ps aux | grep -i '[a]pt\|[d]pkg' - If hanging processes are found, terminate them using
sudo kill -9 PID. - Safely remove stale lock files:
sudo rm -f /var/lib/apt/lists/lock sudo rm -f /var/cache/apt/archives/lock sudo rm -f /var/lib/dpkg/lock* - Reconfigure unfinalised package installations:
sudo dpkg --configure -a
Repair Corrupted Package Lists and Deprecated PPAs
Corrupted repository lists in /var/lib/apt/lists/ immediately cause automated download tasks to abort:
- Clean the local apt package cache:
sudo apt clean - Remove existing package list indexes:
sudo rm -rf /var/lib/apt/lists/* - Run a clean manual package update:
sudo apt update - Review the output carefully. If any PPA or third-party repository produces a
404 Not Founderror or GPG key error, remove that specific repository file from/etc/apt/sources.list.d/.
Test and Restart apt-daily.service Interactively
Once lock files and repositories are clean, run the service manually to verify error-free execution:
- Trigger the download service:
sudo systemctl start apt-daily.service - Check the status output:
systemctl status apt-daily.service - Verify that the status reads
active (exited)with an exit status ofstatus=0/SUCCESS. - Also test the companion upgrade service:
sudo systemctl start apt-daily-upgrade.service systemctl status apt-daily-upgrade.service
Adjust or Disable apt-daily Systemd Timers (Optional)
On battery-powered laptops or development virtual machines where background updates cause high CPU or bandwidth spikes during boot, you can reschedule or disable the timer:
- View the active apt timers:
systemctl list-timers | grep apt - If you prefer to manage package updates manually via
sudo apt update && sudo apt upgrade, disable and mask the automatic download timers:sudo systemctl stop apt-daily.timer apt-daily-upgrade.timer sudo systemctl disable apt-daily.timer apt-daily-upgrade.timer sudo systemctl mask apt-daily.service apt-daily-upgrade.service - Clear any failed unit flags in systemd:
sudo systemctl reset-failed