Sometimes I shutdown Ubuntu and …it takes ages to actually power off.
Am I alone?
Am I unreasonable?
I’m not sure, but I am highly caffeinated — massive props to all the wonderful folks who buy me a coffee (it really does get spent on coffee) ☕️ — and I haven’t written anything for about 5 days.
Which is almost as long as my shutdowns seem to take…
Slow Ubuntu Shutdowns Are Real
See, when I hit shutdown (or run sudo shutdown now
in a terminal) and expect Ubuntu to do the whole “going… to gone” process in around 5-10 seconds, max. I want to be able to close my laptop’s lid, stuff it in my bag, and go buy bread because I’m half pigeon.
And, to be fair, most of the time Ubuntu does do that.
But sometimes …It doesn’t.
Sometimes it hangs.
For ages.
The loading dots on the shutdown screen just keep… dotting.
And it’s really irritating!
As any Linux geek would, I hit esc
to see what’s happening behind the scenes and almost always the message staring back at me is this one:
A stop job is running for Snap Daemon (57s / 1min 30)
That’s a timer on the end. I get to “enjoy” watching the counter slowly tick up, one excruciating second at a time, until, at last, the maximum allowed time is reached and—BLINK—my computer finishes shutting down immediately.
See, Ubuntu allows the Snap Daemon 90 seconds to stop
and, if by that time it doesn’t… 💀.
Is (occasionally) having to endure wait an extra 1 minute and 30 seconds for a shutdown to finish a major issue? No, not unless you’re a mayfly. But it is considerably longer than a shutdown should take, and indeed does take on my other Linux distributions.
Irked from encountering this issue yet again earlier, I went in search of a “fix”.
Fix Slow Shutdowns Due to Snap Daemon
Disclaimer: I am not a snap doctor. I do not know why the snap daemon often refuses to gracefully stop when asked. I do not know how to fix the underlying cause merely treat the symptom.
A nuclear solution™ is to run sudo apt purge snapd
, put on some sunglasses, and head off into a glorious Hollywood sunset.
However, l don’t harbour an ideological allergy to the Snap format, and a number of my favourite command line tools are installed as snaps (honest lol). Plus, y’know, I write about Ubuntu and Snaps are kinda core to the quote Ubuntu experience unquote these days.
But I am done enduring recurrent bouts of WHY IS NOTHING HAPPENING-ness.
That 1 minute 30 seconds I wait for the Snap Daemon to meet its (inevitable) end would be better spent propelling my skinny frame to the nearest artisan bakery, or letting the cat in with DEAR GOD WHAT IS THAT IN YOUR MOUTH SWEET, PRINCESS….
So I reduced the snap daemon timeout from 90 seconds to (still rather patient) 30 seconds – winning back myself an entire minute and probably doing irreparable hard to the snap daemon but yolo.
Want to do it to?
- Open a new terminal window
- Edit
/etc/systemd/system.conf
(as root) in your fave editor - Set
#DefaultTimeoutStopSec=90s
to your desired value - Hit save
- Double check you hit save
Now, next time your system restarts — and I pray the shutdown is swift — the new timeout value will get picked up by the systemd deamon and, all is well. If you don’t want to reboot I think you can run systemctl daemon-reload
instead, but I didn’t do that so you’re on own if it makes things go funky.
Anyway, that’s it.
Obviously this guide is not an official workaround that I’m paraphrasing from snap documentation. Heck, there could be a very good reason why the timeout is as long as it is, and a very good reason why we ought to put up with waiting for the blasted thing to die but…
Having wasted many, many minutes to this — enough to listen to Britney Spears’ Toxic 3 times on repeat (the internet’s standard measure of time) — I’m done.