sebastiano.tronto.net

Source files and build scripts for my personal website
git clone https://git.tronto.net/sebastiano.tronto.net
Download | Log | Files | Refs | README

shutdown.md (4277B)


      1 # The man page reading club: shutdown(8)
      2 
      3 *This post is part of a [series](../../series)*
      4 
      5 I would like to write about more interesting things, but I do not have
      6 time or energy to do so. I need to shut down for a little while.
      7 
      8 ## Sleeping in a sleepless time
      9 
     10 *Reading. Learning. Fun. Tired.*
     11 
     12 ```
     13 $ date 
     14 Thu Jul  7 22:57:50 CEST 2022
     15 ```
     16 
     17 *Not too late. You should do something.*
     18 
     19 ```
     20 $ man man
     21 NAME
     22 	man - display manual pages
     23 ```
     24 
     25 *No, you have already done that one. What should you do?*
     26 
     27 ```
     28 $ date
     29 Thu Jul  7 22:59:48 CEST 2022
     30 ```
     31 
     32 *This is not going anywhere. Is it time to go to sleep? Who knows,
     33 during the covid lockdown - ahem, nuclear winter - every hour looks the same.
     34 Maybe it is time to go to sleep. To shutdown.*
     35 
     36 ## shutdown(8)
     37 
     38 *Follow along at [man.openbsd.org](https://man.openbsd.org/OpenBSD-7.1/shutdown)*
     39 
     40 ```
     41 SYNOPSIS
     42 	shutdown [-] [-dfhknpr] time [warning-message ...]
     43 
     44 DESCRIPTION
     45 	shutdown provides an automated shutdown procedure for superusers to
     46 	nicely notify users when the system is shutting down, saving them from
     47 	system administrators, hackers, and gurus, who would otherwise not bother
     48 	with such niceties.  When the shutdown command is issued without options,
     49 	the system is placed in single user mode at the indicated time after
     50 	shutting down all system services.
     51 ```
     52 
     53 As it sometimes happens, the first few lines of the manual page hint to some
     54 arcane background that you cannot quite grasp. However, the bottom line is
     55 clear: `shutdwon` shuts the system down.
     56 
     57 ```
     58 The options are as follows:
     59 	-d	When used with -h, -p, or -r causes system to perform a dump.
     60 		This option is useful for debugging system dump procedures [...].
     61 ```
     62 
     63 Good to keep in mind. But this time we are not in for an in-depth analysis of
     64 a classic UNIX command. We just want to shut down. Let's skip a few of the
     65 other options.
     66 
     67 ```
     68 	-p	The system is powered down at the specified time.  The -p flag is
     69 		passed on to halt(8), causing machines which support automatic
     70 		power down to do so after halting.
     71 
     72 	-r	shutdown execs reboot(8) at the specified time.
     73 ```
     74 
     75 Yes, these sound like things I would like to do. How do I tell it to
     76 shut down now?
     77 
     78 ```
     79 	time  time is the time at which shutdown will bring the system down and
     80 	      may be the word now (indicating an immediate shutdown) or specify
     81 	      a future time in one of two formats: +number or yymmddhhmm,
     82 	      where the year, month, and day may be defaulted to the current
     83 	      system values.  The first form brings the system down in number
     84 	      minutes and the second at the absolute time specified.
     85 ```
     86 
     87 Great!
     88 
     89 ```
     90 	warning-message
     91 		Any other arguments comprise the warning message that is
     92 		broadcast to users currently logged into the system.
     93 	-	If `-' is supplied as an option, the warning message is read from
     94 		the standard input.
     95 ```
     96 
     97 Who do we have to warn about the shutdown? We are the only user anyway, right?
     98 
     99 ```
    100 # echo 'the hours rise up putting off stars and it is
    101 > dawn' | shutdown -p now -
    102 ```
    103 
    104 ## Conclusions
    105 
    106 At the moment of writing this blog post, I am tired. I had a busy week.
    107 I wanted to write an interesting blog post about something like
    108 sh(1), but I could not find the time. However, shutting down my pc earlier
    109 today inspired me to write this short blog entry.
    110 
    111 `shutdown` is an interesting command. It seems like it should be
    112 straightforward: "computer, please shut down". But the syntax for
    113 this simple instruction is quite complicated, and it offers us many
    114 more options than we would ever want to use, at least in the 21st
    115 century.  Moreover, as indicated by the `#` instead of the `$` in
    116 the last command, one needs superuser privileges to shut down a
    117 classic UNIX system.
    118 
    119 This is because, in the time of mainframes, *shutting down* was not such a
    120 simple operation: multiple users might have been connected to the main
    121 computer, and shutting the whole system down without at least telling them
    122 was rude. At least this is my guess, I was not there at the time.
    123 
    124 It would certainly be interesting to dig into the history of computer systems,
    125 mainframes and how administrators used to shut them down when multiple users
    126 were logged in. But I am not going to do it now.
    127 
    128 Good night.
    129 
    130 *Next in the series: [sh(1) - part 1: shell grammar](../2022-09-13-sh-1)*