Wandering Thoughts archives


The shutdown command is a relic of BSD's historical origins

Most of the remaining Unixes these days have a shutdown command that all look the same; the FreeBSD manpage is about typical, and you can compare it to the Linux manpage. Even Illumos has a version with broadly similar features. I suspect that a bunch of people have used shutdown periodically without thinking about the actual command very much. But if you look at it, shutdown is an interesting relic of BSD's origins as a timesharing system.

I call shutdown a relic here because of its behavior if you tell it to shut the system down at some point in the future, say fifteen minutes from now. If you've never run shutdown this way, what it does is start broadcasting repeated messages about the impending shutdown via wall (or an internal equivalent), disables further logins to the machine shortly before the reboot or shutdown time, and then does the reboot at the time. All of this makes perfect sense in a timesharing environment where the major use of the system is from a bunch of people that are logged in via terminals (whether real serial ones or over the network).

However, this way of doing an extended shutdown doesn't make much sense outside of that sort of timesharing setup, which we can see by what it doesn't have. First, it doesn't have any method of notifying people other than wall to terminal sessions that are visible in utmp. Back in the days, of course, you pretty much couldn't be logged in without being in utmp; these days, you might be logged in but not even running a terminal emulator program (never mind whether or not you're paying attention to it instead of your mail client). A modern take on shutdown would probably be built using a more general (and more complicated) notification scheme.

Second, there's no mechanism to tell running servers and daemons and the like about the impending shutdown, or even ask them to stop taking on new work at the same point that shutdown locks out new regular user logins. The BSD shutdown simply assumes that daemons are unimportant, don't need any advance notice, and can be abruptly dealt with when the shutdown time is reached. This was more or less true on the original Vaxen running 4.x BSD in the 1980s, but is definitely no longer true today on many servers. Almost no one logs into our web server or our mail server or our IMAP server, but they're all in constant use. In those environments, 'shutdown -r 18:00 "some nice message"' is more or less equivalent to 'echo reboot | at 18:00' as far as the net effects go (ie, at 6pm the services all abruptly vanish).

That shutdown is a relic of BSD's origins isn't bad as such, not as far as I'm concerned. It's just interesting. I have a peculiar affection for these historical oddities and lingering remnants of Unix's past.

(Part of it is that it's a reminder that Unix came from deep roots and hasn't had them all carefully scrubbed away and hidden like awkward relatives.)

unix/ShutdownBSDTimesharingRelic written at 01:09:13; Add Comment

Page tools: See As Normal.
Login: Password:
Atom Syndication: Recent Pages, Recent Comments.

This dinky wiki is brought to you by the Insane Hackers Guild, Python sub-branch.