brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: snap restart bounces the services of a snap without a reboot

Snap
~/tips/tip-snap-restart-one-service

snap services

Restart a misbehaving snap service by name, after seeing what it runs.

A snap can ship background services, and their systemd unit names are long and odd. The snap command lets you handle them by the snap’s own name.

Start by listing them:

snap services

You get each service, whether it starts at boot and whether it is running now. Restart a whole snap, or one service inside it:

sudo snap restart lxd
sudo snap restart lxd.daemon

Some services can reload their config without stopping. Add --reload for those:

sudo snap restart --reload lxd.daemon

A service that does not support a reload will not benefit from the flag, so check what the app’s documentation says.

I reach for snap services first when an app installed as a snap stops answering. The state column often tells you right away that it is not running, and then a restart plus a look at the logs is the next step.

A restart drops active connections and anything the service was doing at that moment. On a server that other people use, pick the moment, and do not use a restart loop as a fix for a service that keeps dying. Read its log and find the cause.

Further reading: Snapcraft: Control services

More Snap tips snap refresh --list sudo snap save lxd sudo snap stop --disable lxd.daemon sudo snap alias vlc my-vlc snap saved All Snap tips (14) All topics

Link