Snaps update automatically, and by default, the snapd daemon checks for updates 4 times a day. Each update check is called a refresh.
But when, and how often, these updates occur can be modified with the snap refresh command. Updates can be set to occur on Friday at midnight, for example, or for specific days of the month, such as only the third Monday, or even the last Friday of the month, between 23:00 to 01:00 the next day.
Snaps running in devmode, or installed locally, are typically intended for testing and do not update automatically until they’ve been published and downloaded from the store.
- Manual updates
- Monitor updates
- Control updates
Regardless of when a refresh is scheduled, an update refresh can be initiated with the
snap refresh command:
$ snap refresh gnome-system-monitor 3.28.2 from 'canonical' refreshed gnome-calculator 3.28.2 from 'canonical' refreshed
The refresh command can also be used to see when the last refresh occurred and when the next is scheduled:
$ snap refresh --time timer: 00:00~24:00/4 last: today at 09:16 GMT next: today at 17:39 GMT
The first line in the above output shows the value of the timer system option. This defines how and when a refresh should be scheduled.
To see which snaps are going to be updated with the next refresh, use the additional
$ snap refresh --list Name Version Rev Publisher Notes core 16-2.45.1+git2022.b6b3c25 9584 canonical✓ core get-iplayer 3.26 250 snapcrafters - qt551 5.5 30 keshavnrj -
snap changes and
snap change <change-id> commands to see details about what changed during the last refresh:
$ snap changes ID Status Spawn Ready Summary 2052 Done today at 09:34 BST today at 09:35 BST Auto-refresh 7 snaps 2053 Done today at 15:16 BST today at 15:17 BST Refresh snaps "gnome-calculator", "flock-chat", "gnome-characters", "gnome-system-monitor"
Add the change-id to see what actions a specific change performed:
$ snap change 2053 Status Spawn Ready Summary Done today at 15:16 BST today at 15:16 BST Ensure prerequisites for "gnome-calculator" are available Done today at 15:16 BST today at 15:16 BST Download snap "gnome-calculator" (199) from channel "stable" Done today at 15:16 BST today at 15:16 BST Fetch and check assertions for snap "gnome-calculator" (199) ⋮ Done today at 15:16 BST today at 15:16 BST Start snap "gnome-system-monitor" (54) services Done today at 15:16 BST today at 15:16 BST Clean up "gnome-system-monitor" (54) install Done today at 15:16 BST today at 15:16 BST Run configure hook of "gnome-system-monitor" snap if present
There are two general approaches to postponing or otherwise managing snap updates, with either the
snap refresh --hold command, or with system settings:
Postpone updates with refresh hold
Experimental warning: The hold feature is currently considered experimental. It’s only available in snapd from its edge channel.
snap refresh --hold command holds, or postpones, snap updates for individual snaps, or for all snaps on the system, either indefinitely or for a specified period of time.
snap refresh --hold=<duration> <snap1> <snap2>...
Time duration units can be seconds (s), minutes (m) or hours (h), or a combination of these. A value of
forever is also valid, to postpone updates indefinitely:
$ snap refresh --hold=24h firefox General refreshes of "firefox" held until 2022-10-26T14:10:53+01:00
If no duration is specified, the time duration defaults to
If no snaps are specified, the hold applies to all snaps installed on the system:
$ snap refresh --hold=24h Auto-refresh of all snaps held until 2022-10-26T14:25:58+01:00
However, there are important differences in how a hold is applied, depending on whether individual snaps are specified or not. These differences are described below.
If snaps are specified
The refresh hold is:
- Effective on auto-refreshes and general snap refresh requests
- Not effective on targeted snap refreshes
When one or more snaps are specified, the hold is effective only on their auto-refreshes and general refresh requests from
However, a refresh that targets a held snap specifically will not be blocked and will always be able to proceed.
This can be useful if a snap upgrade is known to be problematic. That specific snap can be held while the remainder of the system is safely refreshed. After the snap upgrade problem has been solved, and a new revision of the snap published, that snap can then be manually refreshed as a specific target. If the upgrade works as expected, the hold can be safely removed (see Remove a hold).
If no snaps are specified
The refresh hold is:
- Effective only on auto-refreshes
- Not effective on general snap refresh requests and targeted snap refreshes
If no snaps are specified, a hold applies to all snaps installed on the system, however the hold is only effective on auto-refreshes and will not block either general refresh requests from ‘snap refresh’, or specific snap requests from ‘snap refresh target-snap’.
Remove a hold
snap refresh --unhold command removes a refresh hold, either for the specified snaps or for all snaps when no snaps are targeted specifically.
For a single snap:
$ snap refresh --unhold firefox Removed general refresh hold of "firefox"
For for all snaps:
$ snap refresh --unhold Removed auto-refresh hold on all snaps
Control updates with system options
There are four system-wide options that manage how updates are handled:
- refresh.timer: defines the refresh frequency and schedule
- refresh.hold: delays the next refresh until the defined time and date
- refresh.metered: pauses refresh updates when network connection is metered
- refresh.retain: sets how many revisions of a snap are stored on the system
Use refresh.timer to modify when, and how frequently, your snaps are refreshed.
The following example asks the system to only refresh snaps between 4.00am and 7.00am, and 7.00pm and 10:10pm:
$ sudo snap set system refresh.timer=4:00-7:00,19:00-22:10
Other examples for the time and frequency option include:
||Mondays at 10:00, Fridays at 15:00|
||Mondays at 10:00 and 15:00, Fridays at 10:00 and 15:00|
||Monday to Wednesday and on Friday, twice between 9:00 and 11:10|
||Mondays, some time between 9:00 and 11:00, and on Wednesdays, some time between 22:00 and 23:00|
||Monday and on Wednesday, at 0:00|
||2nd Monday of the month, through the following Wednesday, between 23:00 and 24:00|
||Last Friday of the month, from 23:00 to 1:00 the next day|
See Timer string format for a comprehensive breakdown of the syntax used to define times and frequencies.
You can check the update frequency for your environment with the
$ snap refresh --time timer: 00:00~24:00/4 last: today at 07:47 BST next: today at 12:13 BST
By default, the snap system is scheduled to refresh four times per day, as shown in the above output.
Use refresh.hold to delay snap refreshes until a defined time and date (up to 90 days). The time and date format needs to conform to RFC 3339.
For example, 5:22pm (BST), Tuesday 23rd April 2019, would look like the following:
The correct format can be generated with the date command:
$ date --date="BST 2019-04-23 17:22:54" +%Y-%m-%dT%H:%M:%S%:z 2019-04-23T17:22:54+01:00 $ sudo snap set system refresh.hold="$(date --date=tomorrow +%Y-%m-%dT%H:%M:%S%:z)" $ sudo snap get system refresh.hold 2019-04-24T17:22:54+01:00
After a refresh, the next refresh can be delayed by up to 90 days, after which a refresh will be performed regardless of the refresh.hold value.
We explicitly format the date command output because the version of date provided by GNU core utilities breaks RFC3339 compatibility when passing the
--rfc-3339argument. See the bug report for further details.
Use refresh.metered to pause and re-enable the refresh process when NetworkManager detects a metered connection, such as an LTE link with a limited data plan.
To hold refreshing snaps when on a metered connection:
$ sudo snap set system refresh.metered=hold
To allow refreshing:
$ sudo snap set system refresh.metered=null
By default, refresh is enabled when a metered connection is detected.
Use refresh.retain to set the maximum number of a snap’s revisions stored by the system after the next refresh:
$ sudo snap set system refresh.retain=3
The refresh.retain value can be a number between 2 and 20. The default is
refresh.retain=3 on Ubuntu Core systems and
refresh.retain=2 on classic Ubuntu systems, such as those running Ubuntu 18.04 LTS (Bionic Beaver) and Ubuntu 16.04 LTS (Xenial Xerus).
Last updated 18 days ago.