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: systemctl freeze pauses a service and thaw lets it continue

Systemctl
~/tips/tip-systemctl-freeze-thaw

sudo systemctl freeze indexer.service

Suspend a busy service for a moment without stopping it.

Sometimes a heavy service needs to be out of the way for a minute, and stopping it would lose its work. Freezing keeps everything in memory.

sudo systemctl freeze indexer.service
# do the thing that needs the CPU or a quiet disk
sudo systemctl thaw indexer.service

All processes in the unit are suspended with the cgroup freezer. They use no CPU while frozen and carry on from the same spot after thaw. You can confirm the state:

systemctl show -p FreezerState indexer.service

I would use it for an indexer or a transcoder that competes with something urgent, or to get a still picture of a process that keeps changing files while I look around.

It needs a system with cgroup v2 and a reasonably recent systemd, so older distributions will refuse.

Frozen processes also stop answering. A web server or database that is frozen leaves clients waiting until they time out, and anything holding a lock keeps holding it. Do not freeze things that others depend on, such as networking or logging. And write the thaw command down before you start, because a forgotten frozen service looks exactly like a hang.

Further reading: systemctl man page

More Systemctl tips sudo systemctl daemon-reload systemctl list-units --type=service --state=running systemctl -H [email protected] status nginx sudo systemctl reboot --firmware-setup systemctl list-jobs All Systemctl tips (9) All topics

Link