How to keep Snap packages up to date with the refresh command

[ad_1]

A programmer works with code.
Image: ThisisEngineering RAEng/Unsplash

I’m all about using the right tool for the right job. With my go-to Linux distribution, I mostly use apt for package installation. However, since some of the applications I use aren’t found in various apt repositories, that package manager does not get the sole responsibility for installing, updating and removing applications from the systems I work with.

SEE: 40+ open source and Linux terms you need to know (TechRepublic Premium)

So, I’ve found myself using Snap packages more and more. Not only are there certain applications I depend on, but Snap is easy to use. For anyone new to the world of Snap packages, you’ll be surprised at how much you can do with this package manager.

Let me show you the various tools Snap has under its belt to help keep your packages up to date.

What you’ll need to use Snap

The only thing you’ll need for this is Snap installed on your operating system and a user with sudo privileges. That’s it, let’s get snappy.

How to update packages with Snap

One thing I like about Snap is that updating packages is much easier than with apt. Instead of having to first update apt and then update the packages, you can do all of this with a single Snap command, such as:

sudo snap refresh

Of course, that’s not all you can do with the refresh command. For instance, you can view when the last time snap refresh was run with the command:

snap refresh --time

The output of the above command will look something like this:

timer: 00:00~24:00/4
last: today at 01:52 EST
next: today at 10:46 EST

Notice the last line, which indicates the next time Snap will be refreshed. That’s right, Snap does auto-refreshing, so you don’t have to. You can also view a list of the Snap packages that will be updated in the next Snap refresh with the command:

snap refresh --list

If you want to see the details of what changed during the most recent snap refresh run, issue the command:

snap changes

You might see output like this:

51   Done    today at 10:18 EST  today at 10:18 EST  Refresh all snaps: no updates

If a Snap package is listed, you’ll see an ID associated with the package. You can get even more details with the command:

snap change ID

Where ID is the ID for the snap package in question.

How to change when Snap is refreshed

You can easily set when Snap packages are automatically refreshed, using refresh.timer. Let’s say you want to only allow Snap packages to be refreshed when you’re not using your machine. We’ll go with any time between 1:00 a.m. and 5:00 a.m. and 7:00 p.m. to 10:00 p.m. To do this, we use the set system option along with refresh.timer like so:

sudo snap set system refresh.timer=1:00-5:00,19:00-22:00

You can also specify days of the week and times. For example, you might want to limit a Snap refresh to, say, Saturday at 10 p.m. and Sunday at 10 p.m., which can be achieved with:

sudo snap set system refresh.timer=sat,22:00,,sun,22:00

You could run them Monday through Friday at midnight with:

sudo snap set system refresh.timer=mon-fri,0:00

You can verify the new fresh times with:

snap refresh --time

You should see something like this in the output:

timer: mon-fri,0:00
last: 2022-11-03
next: tomorrow at 00:00 EST

How to postpone a Snap refresh

This particular feature is in the experimental stage of development and is only available to snapd that is installed from the edge channel. If you try to use this option with the stable version of Snap, it will fail.

What you can do is postpone Snap updates for a particular application. Why would you want to use this option? Say, for example, a particular Snap package has been updated and you want to hold off on upgrading your local version. For that, you can use the –hold option like so:

snap refresh --hold=DURATION PACKAGE

Where DURATION is the period to hold and PACKAGE is the software in question. For example, you might want to place a hold on the Firefox package for the next two days, which can be achieved with:

snap refresh --hold=48h firefox

If you do not specify a duration for the hold, Snap will set the duration to forever. If you don’t specify a package to be held, Snap will place the hold on all installed packages. One thing to keep in mind, however, is that if you specify an app for a hold, it will be effective for auto-refreshes, but not on targeted Snap refreshes. In other words, you could still run a manual refresh on Firefox, and it will update.

To unhold a Snap package, issue the command:

snap refresh --unhold PACKAGE

Where PACKAGE is the software in question.

If you’ve placed a hold on all packages, the unhold command would be:

snap refresh --unhold

Easy update management

Snap makes it fairly easy to update packages and even get specific with when those packages are updated. With the command outlined here, you can not only easily manage your Snap packages, but you can also take control over various aspects of the update.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

[ad_2]

Source link