Halt Versus Shutdown

Home » CentOS » Halt Versus Shutdown
CentOS 10 Comments

Working with different OSs can be quite challenging (mentally :-)).

I wonder why the command “halt” has not same result between EL6 and EL8.

To shutdown the vm or workstation in EL8 i must use “shutdown now”.

Who mandates this behavior in terms of configuration file?

10 thoughts on - Halt Versus Shutdown

  • fwiw, i’ve always used ‘init 0’ to shut down all sorts of unix/linux systems. On old school unix, and I think even early Linux, halt was an
    /immediate/ halt, as in catch fire. might as well hit the power switch.

  • It’s to do with systemd. EL6 used SysV based init and runlevels, EL7 &
    EL8 use systemd targets.

    If you look at the halt and shutdown commands they are symlinks to
    /usr/bin/systemctl now and they are implemented as shims that replicate the effect of the old SysV processes.

    So the following have the same effect:

    “systemctl isolate halt.target”
    “halt”
    “shutdown -H now”
    “systemctl halt”

    there are equivalents for “poweroff” and “reboot” as well.

    P.

  • In EL7/EL8, init is now a symlink as well because everything is controlled by systemd.

    Not quite. Shutdown is a timed thing so you can tell it to shutdown or reboot at a certain time or after a certain delay and it can broadcast messages to the users – it’s useful on multi-user systems to be able to warn users that the system is about to go down. Halt is an immediate thing without any broadcast messages or delay but it does do the halt cleanly. There is an option to halt to not sync the disks – this is not a wise thing to do and is an emergency option – certainly the original man pages for halt said something like “only do this if your disks are on fire”.

    P.

  • I’m quite sure that in original Berkeley Unix, as on the VAX 11/780, halt was an immediate halt of the CPU without any process cleanup or file system umounting or anything. Early SunOS (pre-Solaris) was like this, too.

  • The SunOS 4.1.2 man page for halt says

    NAME
    halt – stop the processor
    SYNOPSIS
    /usr/etc/halt [ -oqy ]
    DESCRIPTION
    halt writes out any information pending to the disks and then
    stops the processor.
    halt normally logs the system shutdown to the system log
    daemon, syslogd(8), and places a shutdown record in the
    login accounting file Ivar/admlwtmp.
    These actions are inhibited if the -0 or -q options are present.

    The BSD 4.3 (that ran on VAXen) man pages say largely similar things:

    https://www.freebsd.org/cgi/man.cgi?query=halt&apropos=0&sektion=0&manpath=4.3BSD+Reno&arch

  • ok, so it does a sync then hard halts, but it doesn’t gracefully exit services, or unmount file systems.

  • Working with different Linux Distributions makes the life harder. So far I have found out that ‘poweroff’ & ‘reboot’ has the same behaviour on Linux/Unix/BSDs.

    Best Regards, Strahil Nikolov

    На 15 юни 2020 г. 5:22:28 GMT+03:00, John Pierce написа:

  • Am 15.06.20 um 05:38 schrieb Strahil Nikolov via CentOS:

    Yeah, poweroff seems the appropriate command instead of halt.

    Thanks for all the “historical” input. Things make now sense :-)

  • Thanks for excurse in the past, whent the world made sense ;-)

    Valeri


    ++++++++++++++++++++++++++++++++++++++++
    Valeri Galtsev Sr System Administrator Department of Astronomy and Astrophysics Kavli Institute for Cosmological Physics University of Chicago Phone: 773-702-4247
    ++++++++++++++++++++++++++++++++++++++++

  • Hmm. If the disks really were “on fire”, my preferred means of shutdown was the big red button by the door as I exited, PDQ.

    Actually I did once have to do this. I was “minding the shop” at lunch time on a sunny day. As I looked into the machine room from the operations office I saw a cloud of smoke arising from the floor through one of the AC vents. Dead stop – building alarm and get out. It turned out that one of the AC units had started its steam generator and the blast was picking up dist mites, which showed up in a shaft of sunshine looking light smoke. Most machines were at the far end of the room and it was only occasionally that that particular unit came on. The fire brigade confirmed that it was the right action, but some of the users were less happy!


    J Martin Rushton MBCS