6

I'm having a bit of trouble with my home server (running Debian 7.7).

When trying to schedule a shutdown, the following occurs:

serverbox:~ $ sudo shutdown -h +10

Broadcast message from root@serverbox (pts/0) (Tue Nov  4 23:56:52 2014):

The system is going DOWN for system halt in 10 minutes!

... Which is great, except the terminal does not return. Shutdown warning messages are still shown, but the terminal prompt does not return. Ending the SSH session or pressing Ctrl+c will result in the shutdown being cancelled.

Can I somehow prevent this behavior? Is this even supposed to happen?

6

Instead of using ctrl + c use ctrl + z to put the action in the background.

Or the better way of doing it would be to add an & at the end like so:

serverbox:~ $ sudo shutdown -h +10 &

The Ampersand: &

The ampersand symbol tells the shell that it should execute the process in the background and return you to the prompt immediately. Normally it waits for the command to finish before returning you to the prompt -- which is not what you want. This is technically called forking the command to the background

  • Thanks, that did the trick. I'm still not exactly sure though, is this normal, expected behavior for Debian? I'm used to the shutdown command not being "modal" like that from my ArchLinux system, so this seems rather counterintuitive. – Toby Nov 4 '14 at 23:20
  • This is pretty normal behavior - Eventually the session will timeout. This is the same thing that happens on RHEL systems. – Christopher Stanley Nov 4 '14 at 23:37
  • Indeed, shutdown is a program that will use wall-like functionality for informational messages and then shut down the system. It is designed to run "interactively" specifically so that a scheduled shutdown can be aborted with a signal or a ^C interactively. – DopeGhoti Nov 4 '14 at 23:56
  • NOTE: Putting an ampersand at the end of a CSH varient shell does what is specified. However, in the case of a SH varient shell, you'd have to put the nohup command before it so that the termination of the TTY session (and the resulting signal) does not terminate the command. – mdpc Nov 5 '14 at 0:52
  • Just to add a little bit to the answer, man page description for -h switch is this: "Requests that the system be either halted or powered off after it has been brought down, with the choice as to which left up to the system. So the reason why it doesn't shutdown as expected is because system decides just to halt, not power off". I usually use shutdown -P +(time in minutes) because -P switch is power-off,which is explicitly telling OS to shutdown – Sergiy Kolodyazhnyy Nov 5 '14 at 3:59

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.