Reducing shutdown timeout for "a stop job is running"
Solution 1
How do I reduce the timeout from 5 minutes to, say, 15 seconds or so?
You re-build systemd from source, patching the hardwired timeout in systemv-sysv-generator
from TimeoutSec=5min
to whatever you want. Or you ask the systemd people for a control knob somewhere in the Fedora/SUSE or LSB headers.
Or, on the gripping hand, you give up on using this rc
script that you have and write a systemd service unit for your service, whose timeouts you can set with an explicit TimeoutSec=
setting, installed with a drop-in settings file in /etc/systemd/system/pm2.service.d/timeout.conf
if necessary.
Given this, this, this, this, this, and others, the first rule for migrating to systemd applies here as well.
Further reading
- https://unix.stackexchange.com/a/316369/5132
- https://unix.stackexchange.com/a/233581/5132
- https://unix.stackexchange.com/a/326354/5132
- https://unix.stackexchange.com/a/316168/5132
- https://askubuntu.com/a/626858/43344
- Jonathan de Boyne Pollard (2015). The systemd House of Horror. Frequently Given Answers.
Solution 2
/etc/systemd/system.conf
has a line
#DefaultTimeoutStopSec=90s
which can be uncommented and changed
Related videos on Youtube
Comments
-
Jason C over 1 year
I've got node.js and pm2 installed on a Pi (Raspbian). PM2 was configured to start via
pm2 startup
and the init scripts it creates. Sometimes when I reboot, shutdown hangs for a few minutes on:A stop job is running for LSB: PM2 init script (... / 5min)
Every once in a while1 what I'm assuming is PM2 doesn't shut down properly and hangs for the full 5 minutes.
On this system, I know exactly what apps PM2 is managing and I really don't care if they shutdown properly.
My question is: How do I reduce the timeout from 5 minutes to, say, 15 seconds or so? Where is this configured?
I read on a forum that it was the
DefaultTimeoutStopSec
key in /etc/systemd/system.conf, so I tried setting that to "15s" but it had no effect. I tried the same thing in /etc/systemd/user.conf, too, but no change. The timeout is still set to 5 minutes.
1 I actually do know specifically what triggers this, but the details aren't important and the effect is unavoidable.
-
Tigger over 7 yearsIf there is a (default)
stop
script, you could re-write it to perform aforcestop
or even to killpm2
instead of a graceful shutdown. -
Jason C over 7 years@Tigger I came to a similar conclusion, actually. Out of desperation I just made
stop
in pm2's init script do nothing at all, and let it die naturally on shutdown. It's a terrible solution for general use but on this particular system it's fine. I still want to know how to change the 5 minute timeout though.
-
-
Stuart Cardall over 5 yearssetting 45s in Arch Linux makes shutdowns quick on an
nvme
drive - for really quick shutdowns use Alpine Linux (nosystemd
) -
Admin almost 2 yearsJust got the "populist badge for this" :-) The wisdom of the masses ...