Re: Linux shutdown sequence



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Kyle wrote:
> Hi,
>
> I wonder if there is a general way of configuring the Linux shutdown
> sequence. E.g to run a script when the user typed shutdown now/telinit
> 0/reboot.

Sure. There are all sorts of ways.

Read the inittab(5) manpage ("man 5 inittab") and take a look at your
/etc/inittab file. In the file, you'll find lines that look like

# What to do at the "Three Finger Salute".
ca::ctrlaltdel:/sbin/shutdown -t5 -r now

# Runlevel 0 halts the system.
l0:0:wait:/etc/rc.d/rc.0

# Runlevel 6 reboots the system.
l6:6:wait:/etc/rc.d/rc.6

# What to do when power fails.
pf::powerfail:/sbin/genpowerfail start


The lines that contain a 0 between the first and second colon (in the example
above, the line that starts "l0:0:" is one) are instructions to init on what
to do when entering runstate 0 (the runstate that you get when you "shutdown
- -h" or "telinit 0" or "halt"). There are other lines (the ones with a 6
between the 1st and 2nd colon) that are run when entering runstate 6 (the
runstate that you get when you "shutdown -r" or "telinit 6" or "reboot").

Each of these lines names a script or program to be run, and each line is
executed in sequence. You can
- - locate a script that is currently executed from your inittab when you
shutdown, and add your script logic to it, or
- - add your own script to /etc/inittab using the appropriate syntax to have it
invoked on shutdown

In the above example inittab (from Slackware 10.1), if I wanted to add logic
that runs one of my own scripts when the user types "shutdown", I could add
logic to the /etc/rc.d/rc.0 (for halt) and /etc/rc.d/rc.6 (for reboot) scripts
identified by the l0 and l6 inittab entries, or I could add a new line to
/etc/inittab, /before/ the l0 and l6 lines that read something like
lx:06:wait:/etc/rc.d/rc.local.shutdown
and put my custom logic into the (new, local) /etc/rc.d/rc.local.shutdown script

Does this help?
- --
Lew Pitcher

Master Codewright & JOAT-in-training | GPG public key available on request
Registered Linux User #112576 (http://counter.li.org/)
Slackware - Because I know what I'm doing.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.7 (GNU/Linux)

iD8DBQFDwGhZagVFX4UWr64RAtJpAKDJZLVz7b2+TZ6BaQRwxm879F610ACfdyTX
kHrV+JWHJbqBRr/gnBAsZwU=
=6pO5
-----END PGP SIGNATURE-----
.



Relevant Pages

  • Re: VBscript that restart the domain comptuer
    ... If you have a shutdown script that cleans up the profiles, ... permissions can restart all computers in a list remotely. ... I have already VB script I ...
    (microsoft.public.windows.server.active_directory)
  • RE: Finetuning: Remote Shutdown with WMI, some errors occur.
    ... Also we would like that a workstation that's locked is also shutdown by this ... script to shutdown all approx. ... Dim strBase, strFilter, strAttributes, strQuery, objRecordSet ... Const OpenAsDefault = -2 ...
    (microsoft.public.windows.server.scripting)
  • RE: Script or Other Method to Reboot
    ... > We need different privileges when using Shutdown command and shutdown the ... > that only administrator will use command to shutdown the computers. ... > we may need to compile the script. ...
    (microsoft.public.windowsxp.configuration_manage)
  • Re: Finetuning: Remote Shutdown with WMI, some errors occur.
    ... Allows shutdown, poweroff, or reboot of multiple remote systems. ... - generic unhandled script compile or runtime error; ... "Specify 1 and only one shutdown action" ... Dim erNumber, erDesc ...
    (microsoft.public.windows.server.scripting)
  • Re: SBS 2003 R2 Shutdown Problem
    ... The other thing I would do if I had a Trend environment is to do a similar script for Trend as I have done for Exchange. ... scripts that first shutdown Exchange, ... If you create a group policy object - computer shutdown script then you need not worry about forgeting - it'll just run for you! ...
    (microsoft.public.windows.server.sbs)