apt-get update schedule adjust

Binary Bandit

Well-Known Member
Dec 13, 2018
56
8
48
52
Hi All,

I'd like to change the schedule that's in place for running "apt-get update" with the default install.

Is this possible? (I don't see where / how it's scheduled now.)

Any warnings?

best,

James
 
Hi,

yes, you can edit this in the systemd timer file
pve-daily-update.timer
 
Hi Wolfgang,

Thank you for the reply. Once again I'm learning something new. I'm used to looking for cronjobs.

Would you help me to find the correct Systemd Timers to change?

systemctl list-timers shows this:
NEXT LEFT LAST PASSED UNIT ACTIVATES
Mon 2019-05-06 12:17:00 PDT 35s left Mon 2019-05-06 12:16:00 PDT 24s ago pvesr.timer pvesr.service
Mon 2019-05-06 17:13:50 PDT 4h 57min left Mon 2019-05-06 02:59:00 PDT 9h ago apt-daily.timer apt-daily.service
Mon 2019-05-06 19:31:00 PDT 7h left Sun 2019-05-05 19:31:00 PDT 16h ago systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Tue 2019-05-07 05:28:16 PDT 17h left Mon 2019-05-06 04:10:00 PDT 8h ago pve-daily-update.timer pve-daily-update.service
Tue 2019-05-07 06:10:03 PDT 17h left Mon 2019-05-06 06:58:00 PDT 5h 18min ago apt-daily-upgrade.timer apt-daily-upgrade.service

I'm not sure if it's apt-daily.timer, pve-daily-update.timer or apt-daily-upgrade.timer. It looks like pve-daily-update.timer is used to update my proxmox subscription and doesn't need to be changed. That leaves me with apt-daily.timer and apt-daily-upgrade.timer.

apt-daily.timer is related to apt-daily.services and executes "apt.systemd.daily update". This seems like the one that I want to modify?

apt-daily-upgrade.timer is related to apt-daily-upgrade.service and executes "apt.systemd.daily install". I wasn't aware that updates were being installed automatically. Am I misinterpreting this?
 
Systemd timers has a bit of a learning curve! To help the next person who finds this thread here's what I did. It took a lot of piecing things together from other threads and Google searches.

My goal is to change pve-daily-update.timer from a daily schedule to a weekly schedule. That is from every day at a given time to only Thursday's at a given time.

First, take a look at what systemd timers are scheduled:
Code:
root@ait1:/# systemctl list-timers
NEXT                         LEFT     LAST                         PASSED       UNIT                         ACTIVATES
Tue 2019-05-07 09:56:00 PDT  13s left Tue 2019-05-07 09:55:00 PDT  45s ago      pvesr.timer                  pvesr.service
Tue 2019-05-07 19:20:01 PDT  9h left  Mon 2019-05-06 19:20:01 PDT  14h ago      systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Tue 2019-05-07 21:32:56 PDT  11h left Tue 2019-05-07 09:55:44 PDT  1s ago       apt-daily.timer              apt-daily.service
Wed 2019-05-08 03:25:52 PDT  17h left Tue 2019-05-07 04:20:52 PDT  5h 34min ago pve-daily-update.timer       pve-daily-update.service
Wed 2019-05-08 06:29:23 PDT  20h left Tue 2019-05-07 06:21:41 PDT  3h 34min ago apt-daily-upgrade.timer      apt-daily-upgrade.service

5 timers listed.
Pass --all to see loaded but inactive timers, too.

next edit the pve-daily-update.timer file:
Code:
 nano /etc/systemd/system/timers.target.wants/pve-daily-update.timer

pre-edit:
Code:
[Unit]
Description=Daily PVE download activities

[Timer]
OnCalendar=*-*-* 2:00
RandomizedDelaySec=4h
Persistent=true

[Install]
WantedBy=timers.target

post-edit:
Code:
[Unit]
Description=Daily PVE download activities

[Timer]
OnCalendar=Thu *-*-* 2:00
RandomizedDelaySec=4h
Persistent=true

[Install]
WantedBy=timers.target

Notice that I added "Thu " in front of "*-*-*". This chenges the schedule to only run on Thursday rather than every day.

Next load the changes:
Code:
root@ait1:/# systemctl daemon-reload

Check the results:
Code:
root@ait1:/# systemctl list-timers
NEXT                         LEFT           LAST                         PASSED       UNIT                         ACTIVATES
Tue 2019-05-07 10:04:00 PDT  1s left        Tue 2019-05-07 10:03:00 PDT  57s ago      pvesr.timer                  pvesr.service
Tue 2019-05-07 18:48:54 PDT  8h left        Tue 2019-05-07 09:55:44 PDT  8min ago     apt-daily.timer              apt-daily.service
Tue 2019-05-07 19:20:01 PDT  9h left        Mon 2019-05-06 19:20:01 PDT  14h ago      systemd-tmpfiles-clean.timer systemd-tmpfiles-clean.service
Wed 2019-05-08 06:30:52 PDT  20h left       Tue 2019-05-07 06:21:41 PDT  3h 42min ago apt-daily-upgrade.timer      apt-daily-upgrade.service
Thu 2019-05-09 04:19:02 PDT  1 day 18h left Tue 2019-05-07 04:20:52 PDT  5h 43min ago pve-daily-update.timer       pve-daily-update.service

5 timers listed.
Pass --all to see loaded but inactive timers, too.

Notice that the last line / line for pve-daily-update.timer now shows that it starts on Thu? Compare this to Wed as shown at the start of this post.
 
  • Like
Reactions: jerry
OK ... lesson learned ...

--- the last post is correct ... but ... it missed that an update can overwrite the:

/etc/systemd/system/timers.target.wants/pve-daily-update.timer

file and remove any changes.

More Googling and new strategy:

1) list the file that we would like to change:
cat /etc/systemd/system/timers.target.wants/pve-daily-update.timer

2) copy the text to your clipboard (I'm in MS Windows)

3) create a blank override file for pve-daily-update.timer:
systemctl edit pve-daily-update.timer

4) paste the text from step 2 into the file

5) edit as needed ... in my case I added "Thu" again

6) exit and save

7) check your work:
systemctl list-timers

I found that "systemctl daemon-reload" wasn't needed.

I'm waiting and watching now ... hopefully this will do the trick.
 
  • Like
Reactions: urosss

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!