Ubuntu automatically checks and updates all installed Snap packages 4 times every day. Here’s how you can delay or assign a certain time period for the automatic update.
Snap is an Ubuntu developed universal package format that runs in sandbox. Few core apps (such as Ubuntu Software and Firefox in 22.04) and many software in Ubuntu Software are Snap packages. Unlike classic .deb
package, snap updates all the packages automatically in the background silently without user intervention.
If you didn’t block the Snap package, you must have some installed on your Ubuntu machine. And, to avoid conflict to daily work (e.g., online meetings, data backup), you may tell Snap when to do the updates.
Check when Snap will do updates:
By default, snap check (and install if any) updates 4 times per day. You may verify it by pressing Ctrl+Alt+T on keyboard to open terminal and run command:
snap refresh --time
Besides the time period and frequency, it also tells when the last done and next will occur.
Hold or Completely Disable Automatic Updates
The developer team finally added the --hold
parameter, so user can hold updates for either certain app or all snaps for given time or indefinitely.
NOTE: the commands below work only for edge channel of snapd daemon at the moment of writing.
Simply open terminal and run command, and run command to hold updates for 24 hours via command:
snap refresh --hold=24h firefox
Or completely disable automatic updates for firefox via:
snap refresh --hold firefox
To disable automatic updates for all snap applications, run command:
snap refresh --hold
To re-enable automatic updates, use command to unhold all:
snap refresh --unhold
Or unhold specified app via command:
pre>snap refresh –unhold firefox
Specify time period for Snap update
To tell when and how often to check updates, it can be done by running a single command in terminal to set the value of “refresh.timer”.
For example, to allow only between 4.00am and 6.00am, and 9.00pm and 12.00pm, use command:
sudo snap set system refresh.timer=4:00-6:00,21:00-24:00
Or, only check/install updates twice in weekend via command:
sudo snap set system refresh.timer=sat,sun,0:00-24:00/2
Other examples include between 10.00pm and 11.00pm from Monday to Wednesday, and between 9.00am and 11.00am on Friday.
sudo snap set system refresh.timer=mon-wed,22:00-23:00,,fri,9:00-11:00
Or second Monday of the month between 9:00 and 11:00 via command:
sudo snap set system refresh.timer=mon2,9:00-11:00
Delay the update
Ubuntu supports to delay snap updates by specifying a value to “refresh.hold” up to 90 days.
1. Firstly, in case you don’t know your time zone short name, run command:
date
It will output the current date and time, as well as time zone (e.g., NST, AST, EST, PST, CST).
2. Next, use the command below to convert your desired time (e.g., July 7, 2022) to the right format:
date --date="CST 2022-07-07 18:22:00" +%Y-%m-%dT%H:%M:%S%:z
Replace the time zone, date and time in bold. And, copy the output time for use in next command.
3. Finally, delay snap refresh until the given date and time.
sudo snap set system refresh.hold=2022-07-07T18:22:00+08:00
To verify the change, use command:
sudo snap get system refresh.hold
Prevent update when on metered connections
If you’re running Ubuntu on a metered network connection. Which mean you have limited amount of data per month or day. You can prevent Snap from doing updates by running command:
sudo snap set system refresh.metered=hold
To undo this change, use command:
sudo snap set system refresh.metered=null