How to control when daily automatic Ubuntu updates happens

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Hello, friends. In this post, you will learn how to control when daily Ubuntu updates happens. This post although simple is quite useful if you have home test servers.

As we know, Ubuntu 22.04 integrates several important options to automate system updates. This saves sysadmin time and effort.

But not everything is happiness, there are also times when we need to modify some parameters of those updates to avoid some problems that may arise.

Let’s start.

Control when daily Ubuntu updates happen

The first thing to do is to update the system as usual

sudo apt update
sudo apt upgrade

apt daily timers are run by systemd, this can be checked by running:

systemctl list-timers | grep apt

You will get an output screen like this

Thu 2022-12-01 06:51:07 UTC 7h left n/a n/a n/a apt-daily-upgrade.timer apt-daily-upgrade.service
Thu 2022-12-01 07:39:40 UTC 8h left n/a n/a n/a apt-daily.timer apt-daily.service

As you can see, two tasks are done. The first is associated with an apt update and the second with an apt upgrade.

The next step is to find out where these configuration files are located. This is simple, you can do this by running.

systemctl status apt-daily.timer | grep loaded

And

systemctl status apt-daily-upgrade.timer | grep loaded

Sample output

Automatic updates configurations
Automatic updates configurations

You will notice that both are in /lib/systemd so we can’t edit it directly.

To complete this, we will overwrite it in /etc.

Copy them.

sudo cp /lib/systemd/system/apt-daily.timer /etc/systemd/system/
sudo cp /lib/systemd/system/system/apt-daily-upgrade.timer /etc/systemd/system/

And now if you edit them with any text editor, for example I’ll edit the first one

sudo nano /etc/systemd/system/apt-daily.timer

You will see an output like this:

How to control when daily automatic Ubuntu updates happens
How to control when daily automatic Ubuntu updates happens

It is within the TIMER section that you have to make the respective changes. Especially in oncalendar as there you will be able to set the exact time it will run.

Save the changes and close the editor. Then you are done.

Conclusion

Knowing more about an Ubuntu server will help you to manage it better and get the most out of it. Today, you learned how to control when the daily Ubuntu updates happen.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Angelo
Angelo
I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook