LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Why does 'halt' require '-p' to turn off the computer? (https://www.linuxquestions.org/questions/linux-newbie-8/why-does-%27halt%27-require-%27-p%27-to-turn-off-the-computer-4175506969/)

maples 06-03-2014 10:20 PM

Why does 'halt' require '-p' to turn off the computer?
 
This is more of a curiosity question than an actual problem.

If you run
Code:

halt
the OS shuts down, but the computer's power stays on, and to turn it off you have to press and hold the power button. I don't see why this is useful. Maybe someone has a different view on it?

Randicus Draco Albus 06-04-2014 12:22 AM

When I shut down from a terminal, I use:
Code:

shutdown -h now
The system shuts down and the machine powers off. In fact, I have never used the -P option. If the command you are using is simply halt, perhaps it puts the systems into hibernation? I do not know, just guessing.

pan64 06-04-2014 12:51 AM

you can find a lot of threads on the net about it, like these: http://www.computerhope.com/unix/uhalt.htm and http://serverfault.com/questions/191...r-off-and-halt.
The most important difference is that halt will not send ACPI commands to the power supply. Long time ago those power supplies could not be set to off by ACPI, just by hand. Nowadays you are allowed to stop your box this way or automatically switch power off too.
So you can say, historical reason...

Randicus Draco Albus 06-04-2014 12:53 AM

I love history. Thanks.

Soadyheid 06-04-2014 03:31 AM

As an alternative, I tend to use
Code:

halt -i0 -g0 -y
I believe
Code:

halt
does just that... It stops further processing and the everything is in a halted state. I think that
Code:

continue
at this point would resume any processes which were halted.

BTW, In the words of Egon Spengler, I believe that
Code:

halt
then powering down via the big grey button is a BAD thing, as you could lose data. You should use
Code:

halt
sync
sync

instead to write any cached info back to disk before powering off.

IBM, (doncha love 'em; dasd = Disk, ROS = ROM) have to be different with
Code:

halt -F
used to shut down AIX boxes as I recall. :D

Play Bonny!

:hattip:

pan64 06-04-2014 03:42 AM

as far as I know you should first sync (twice), before halt. You cannot do anything if system was halted. That continue does not exist (or it is called warm boot probably).

Soadyheid 06-04-2014 05:10 AM

@pan64
You are, of course, absolutely correct. Is there not a way out of a halt situation? I thought there was. Maybe I'm confusing it with a
Code:

<stop> A
on a Sun box which drops you to the OK prompt where
Code:

continue
will resume.

Play Bonny!

:hattip:

maples 06-04-2014 08:46 AM

Thanks for the insights!

On the computers I've used, 'halt' runs the computer through its normal shutdown routine (at least, I see all the same messages on the screen) and when it's done it sits there. I can't type 'sync' or 'continue' because the cursor is frozen.

After I posted this thread, I started to think about it, and my thoughts were like what pan64 said, that omitting the '-p' doesn't send the 'power off' command to the PSU.

TroN-0074 06-04-2014 10:21 AM

I normally, to turn my computer off as root just type
Code:

poweoff
Or
Code:

sudo poweroff
in a sudo base distro like Ubuntu


All times are GMT -5. The time now is 03:13 AM.