Unattended Upgrades - Runs twice daily at different times instead of once daily at a specific time?

Hi, I am running Ubuntu Mate 16.04 on a Pi2. I have setup unattended-upgrades to update package lists every week.

According to the logs, unattended-upgrade runs every day at around 6am and 12pm. I only want it to run once a day at a specific time (when I’m not using the system). I have already tried the following: https://askubuntu.com/questions/824718/ubuntu-16-04-unattended-upgrades-runs-at-random-times but it doesn’t seem to work for me. How can I get unattended-upgrades to run ONCE a day at a SPECIFIC time ?

Thanks

Hi @rph,

you can use gnome-schedule.
to install it, run

sudo apt install gnome-schedule

then open the program via the menu or the terminal

gnome-schedule

now you can create the task "update" as shown in the picture.

hope it helped. :grinning:

best wishes :smirk:

Mickey

I’ve played with the “unattended-upgrades” package a fair deal (link) so I would double check /etc/apt/apt.conf.d/20auto-upgrades to include APT::Periodic::Unattended-Upgrade "1"; as that specifies the script will run “every 1 day.” As for specifying the exact time, that may be governed by your daily apt activities – which is ultimately spelled out in systemd’s timer. Read the manual on crontab, and then re-read it again, and then edit to your liking (with care):

sudo nano /etc/crontab

P.S. There’s a random number between 0 and 30 minutes before the script actually runs, and for good reason.

@daniel66666 My 20auto-upgrades file:

APT::Periodic::Update-Package-Lists "7";
APT::Periodic::Download-Upgradeable-Packages "0";
APT::Periodic::AutocleanInterval "7";
APT::Periodic::Unattended-Upgrade "1";

My crontab:

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user	command
17 *	* * *	root    cd / && run-parts --report /etc/cron.hourly
25 14	* * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 14	* * 7	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 14	1 * *	root	test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#

And finally, part of my unattended-upgrades log for the 27th March:

2018-03-27 06:00:48,906 INFO Initial blacklisted packages: 
2018-03-27 06:00:48,911 INFO Initial whitelisted packages: 
2018-03-27 06:00:48,913 INFO Starting unattended upgrades script
2018-03-27 06:00:48,915 INFO Allowed origins are: ['o=Ubuntu,a=xenial', 'o=Ubuntu,a=xenial-security', 'o=UbuntuESM,a=xenial', 'o=Ubuntu,a=xenial-updates', 'o=PMS armv7,a=']
2018-03-27 06:01:14,523 INFO No packages found that can be upgraded unattended and no pending auto-removals
2018-03-27 14:02:48,814 INFO Initial blacklisted packages: 
2018-03-27 14:02:48,817 INFO Initial whitelisted packages: 
2018-03-27 14:02:48,819 INFO Starting unattended upgrades script
2018-03-27 14:02:48,821 INFO Allowed origins are: ['o=Ubuntu,a=xenial', 'o=Ubuntu,a=xenial-security', 'o=UbuntuESM,a=xenial', 'o=Ubuntu,a=xenial-updates', 'o=PMS armv7,a=']

As you can see it’s running twice a day. At around 06:00 and 14:00. Although these times are different each day by up to an hour or so (definitely more than 30 minutes). As far as I can see my crontab and 20auto-upgrades file are fine, so why is it doing this ?

Thanks

So to clarify, I only want the upgrades to run at around 14:00 (with a 30 minute randomization) not at 06:00 also. Any ideas on how I can achieve this ?

Why do you have Update-Package-Lists at 7 and Download-Upgradeable-Packages at 0?

Because as far as I can see, “upgrade” automatically downloads the updates and then installs them. So I don’t need to “download” the updates separately.

This configuration would attempt to update your system every minute from 12am to 12:59am. I'd select the "basic" configuration instead and select "every day" (assuming that's an option.)

Set them at 1 and 1 instead and see if that changes anything. Also check to see if you have a user-defined cron per crontab -e

Oh I forgot to mention that I only want it to do the updates once a week. Hence why “Update-Package-Lists” is set to 7 (every 7 days). Technically, “unattended-upgrade” should also be set to 7 but with the randomisation I was worried that it would maybe try and upgrade before the packages have been updated, thus meaning that I go for another week without the updates being installed.

I do. But it is empty.

I have also noticed that the line:

INFO No packages found that can be upgraded unattended and no pending auto-removals

does not appear for the upgrade that runs at around 2pm. This may be of some significance to solving this problem ?

I have the exact same issue as well where it’s running twice a day according to my logs on both my 16.04 LTS and 18.04LTS ubuntu servers. Any help would be appreciated, thanks!