Can I somehow reduce the time it takes Tor to shutdown? In my log I see

Interrupt: we have stopped accepting new connections, and will shut down in 30 seconds. Interrupt again to exit now.

Since I am running it as service I could send it a signal to stop, but I would prefer a configuration-wise solution?


The short answer "you can't", the description is: after sending a termination signal - it's wise to let the network find another chains, so that's why there's a delay in order, and there's absolutely nothing wrong with it. To reduce the delay - it does not works all the times - you can set via ControlPort "DisableNetwork 1" and give Tor 5-10 seconds, then you'll shut it down. But it does not works faster all the times, so - as my advise - just let it finish itself in a regular way, there's no hurry.


But as a side note - you should script the 2nd interrupt shutdown for emergency shutdown cases, like your UPS battery is almost gone: the faster the shutdown is in that cases - the better, because it will prevent the filesystem corruption. Usual shutdown timings for tor are about 10-15 seconds as for me, so - thats' the strategy I'm proposing for your "fast shutdown case":

  • If you're using SystemD - then you have nothing to worry about, as I've switched on it on some of my VMs, it's not a problem at all in case of Debian stretch - VM shuts itself down in 2-5 seconds more time than just a blank one.
  • If you're using daemontools and/or init.d scripts - just send a "DisableNetwork 1" a 2-3 seconds before sending the shutdown machine-wide via shutdown command, that's how it working in my old-style setups I was talking about in original answer. a good workaround here can be the next trick: rename the original shutdown-commands binaries to something like shutdown.orig, make your own scripts with the original command names - and in that scripts before calling "the orig's" do the telnetting "disablenetwork 1" and sleep for 3 seconds. That's exactly how I'm doing it. So all of your previous machine management scripts will be working as usual, no need to patch every of them - just put scripts at the exact place of the old binaries.

That's it!

  • I run Tor in a VM and the long VM shutdown time is annoying. It does not happen often that I have to restart the host system, so my best bet is to script another interrupt at shutdown for those occasions it seems. – Spikolynn Oct 13 '17 at 13:11
  • Well, usually rebooting Tor VM even without the disable network, I rarely get the shutdown time greater than 20 seconds. – Alexey Vesnin Oct 13 '17 at 23:11
  • @Spikolynn added the details about an emergency shutdown and how exactly I'm doing the shutdown – Alexey Vesnin Oct 14 '17 at 1:54
  • You can. Setting ShutdownWaitLength to a smaller value such as 20 seconds is completely reasonable and will not disrupt the network. – nobody Oct 15 '17 at 13:58
  • @nobody yes, it's physically tweakable - even in source - but no it is not a good practice. The "wait length" is not a must-limit, it is a "hard limit", and - if you'll take a deeper look at the keepalives e.t.c. timeouts default values - it's EXACTLY 30 seconds. As soon as your node will close all the links - it will collapse to shutdown, so this particular timing - IMHO - is not the one messed with – Alexey Vesnin Oct 15 '17 at 14:02

There is a graceful way to do this. Putting ShutdownWaitLength 1 in your torrc just works.

  • a kind of a bad prctice - see my comment – Alexey Vesnin Oct 15 '17 at 14:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.