Posted in Linux

A stop job is running for Snap daemon on Ubuntu [Soulution and Thinking]

Ubuntu has a snap service built in, sometimes it is hard to kill when reboot or shutdown. If the progress cannot be killed easily, system will handle some time (default value is 90s).

So one solution is change the killing time for progress.

First, we need to have Administrator Permission on Linux. Execute the command:

sudo su

Then follow the message on screen to enter your passwords.

Next we need to edit system files:

“Nano” is a text editor built in Ubuntu, so we can use it. Execute the command:

nano /etc/systemd/system.conf

Don’t be fear because you will find nearly all the text is blue. Why? Because they all comment out with “#” so that no line is effective for the system. What we need to do is uncomment a line and let that line effect.

Use your keyboard arrow keys to move cursor down to find a line called:

#DefaultTimeoutStopSec=90s

Delete the # and change the time to be 10s, like below:

DefaultTimeoutStopSec=10s

You’ll find the color becomes white because it will be effective for the system.

Then press your keyboard with Ctrl+X, you will see the message on the screen to remind you to save changes. We press Y on the keyboard. Then it shows that you can change the file name, but we do nothing, just press Enter key directly.

Use cat command to see the contents of the edited file.

cat /etc/systemd/system.conf

If you are sure there is no error of that file, then you can reboot your system to see the effect, but may be only the second time to reboot will see the effect. You will see the kill time when shutdown will only be 10s. That’s fine.

To reboot quickly, use command:

reboot

But why Snap cannot be stopped as usual? If you’re using Virtual Machine, I think the answer should be there: maybe the snap service in Ubuntu has conflict with Virtual Machine software.

For example, while using VirtualBox, I just use snapshot function restored a snapshot for my Ubuntu server, the conflict will be there. If you just use the console to normally shut down several times, the problem will be gone. To normally shut down, just close the VM window and choose the second option to shut down.

I have changed the system config to 10s once before but I have never seen stuck any more after I normally shut down the machine.

Good luck to you!