46

I'm familiar with and use shutdown in Linux, and typically just do

> shutdown -h now

But is there a way to stop shutdown from happening, say if I aim to shutdown 10 minutes from now and then in 5 minutes' time I discover I really don't want to shut down?

David
  • 17,673
  • 10
  • 68
  • 97

4 Answers4

103

shutdown -c  is "cancel shutdown" on reasonably recent shutdowns.

The syntax also supports shutdown -c <message> for announcement purposes, so that's handy if other people use the machine.

chaos
  • 122,029
  • 33
  • 303
  • 309
45

You can use  ps  to find the shutdown process and abort it, for example with ps|grep shutdown.

Alternate and less eyeball-intensive versions of this:

pkill shutdown
killall shutdown
kill `cat /var/run/shutdown.pid`
chaos
  • 122,029
  • 33
  • 303
  • 309
skiphoppy
  • 97,646
  • 72
  • 174
  • 218
  • 2
    so `pkill shutdown` would work? – David Feb 08 '09 at 20:45
  • 1
    Yeah. Seems suboptimal if (and only if) your shutdown supports -c, though. – chaos Feb 08 '09 at 21:19
  • 2
    Alternatively: "killall shutdown" – Adam Rosenfield Apr 12 '09 at 03:11
  • Hmm... I thought shutdown only ran long enough to change the run level... He's probably asking how to get init to STOP shutting down. – dicroce May 06 '09 at 23:24
  • @dicroce: If you start a shutdown scheduled for some future time, like he talks about in the question, shutdown runs (hangs out, really) until it's time to actually shut down. The question is how to stop it during that time. – chaos May 17 '09 at 22:01
  • On OS X this cancels shutdown but then you need to delete /etc/nologin because it causes that only root can log in. – skywalker Dec 28 '15 at 11:23
11

If you're a second late on the draw for shutdown -c, and already root on the console, a very fast # init 5 will cancel a shutdown after init changes runlevel.

NOTE: This answer is mostly obsolete now. init 5 isn't very useful on systemd, which, sadly, most systems now use.

Joshua
  • 40,822
  • 8
  • 72
  • 132
8

From shutdown's man page on BSD systems:

A scheduled shutdown can be canceled by killing the shutdown process (a SIGTERM should suffice).

chaos
  • 122,029
  • 33
  • 303
  • 309
Chris Bunch
  • 87,773
  • 37
  • 126
  • 127