views:

3001

answers:

4

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?

+11  A: 

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`
skiphoppy
so `pkill shutdown` would work?
David
Yeah. Seems suboptimal if (and only if) your shutdown supports -c, though.
chaos
Alternatively: "killall shutdown"
Adam Rosenfield
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
@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
+33  A: 

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
Which distro is that for? http://man.cx/shutdown doesn't mention a -c flag.
David
But this does: http://linux.die.net/man/8/shutdown
David Zaslavsky
Exists on vaguely recent Debian, dunno what else.
chaos
Works on current versions of Redhat distros.
dagorym
I was just looking this up in Ubuntu last night; it's in the man page for their version... well, the system shutdown just as I read that, though!
Alex JL
+4  A: 

From shutdown's man page on BSD systems:

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

Chris Bunch
+4  A: 

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.

Joshua