Re: Linux shutdown sequence
- From: Lew Pitcher <lpitcher@xxxxxxxxxxxx>
- Date: Sat, 07 Jan 2006 20:18:17 -0500
-----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-----
.
- References:
- Linux shutdown sequence
- From: Kyle
- Linux shutdown sequence
- Prev by Date: Re: Linux shutdown sequence
- Next by Date: Re: how to copy and NOT overwrite
- Previous by thread: Re: Linux shutdown sequence
- Next by thread: Re: Linux shutdown sequence
- Index(es):
Relevant Pages
|