UTERMINAL
TERMINAL
NEXT
$V1$
NEXT3
$PROMPT$
PAUSE
PAGETURNER
ENCORE5
ENCORE
BOX
FILE
GO
shutdown
SYNTAX
/etc/shutdown
FUNCTION
shutdown is the shell script for a graceful
automated system shutdown.
The actions of shutdown are practically the
reverse of /etc/rc. The shutdown
process transfers the machine from the multi-user
to the single-user mode. Among many chores
the principal ones for shutdown are:
1. Warning users of an impending system shutdown.
2. Killing off daemon tasks.
3. Sync(ing) and halting the processor.
4. Unmounting the file systems.
Let us look at some entries in an /etc/shutdown file.
# Bring the system down gracefully and ruthlessly.
# Read in minutes till shutdown.
echo "Minutes till shutdown? (0-15): "
read num
sleeptime=`expr $num \* 60` # seconds
echo "UNIX will shutdown in $num $min." | wall
echo "Please finish and log off." | wall
sleep $sleeptime # Grace period
echo "All User Processes Now will be killed"
killall # kill all non-shutdown processes
sync
echo " Unmounting the file systems"
/etc/umount /dev/rgb0e 2>/dev/null
echo "Entering Single User Mode"
init s
Lines:
read num and sleeptime=`expr $num \* 60`
obtain and set the grace period.
# Bring the system down gracefully and ruthlessly.
# Read in minutes till shutdown.
echo "Minutes till shutdown? (0-15): "
read num
sleeptime=`expr $num \* 60` # seconds
The line: sleep $sleeptime
is the actual grace period being exercised
# Bring the system down gracefully and ruthlessly.
# Read in minutes till shutdown.
echo "Minutes till shutdown? (0-15): "
read num
sleeptime=`expr $num \* 60` # seconds
echo "UNIX will shutdown in $num $min. "
echo "Please finish and log off."
sleep $sleeptime # Grace period
The line: killall
will kill all outstanding processes (after
the grace period has expired)
# Bring the system down gracefully and ruthlessly.
# Read in minutes till shutdown.
echo "Minutes till shutdown? (0-15): "
read num
sleeptime=`expr $num \* 60` # seconds
echo "UNIX will shutdown in $num $min." | wall
echo "Please finish and log off." | wall
sleep $sleeptime # Grace period
echo "All User Processes Now will be killed"
killall # kill all non-shutdown processes
The line: sync
flushes the outstanding I/O buffers to disk.
# Bring the system down gracefully and ruthlessly.
# Read in minutes till shutdown.
echo "Minutes till shutdown? (0-15): "
read num
sleeptime=`expr $num \* 60` # seconds
echo "UNIX will shutdown in $num $min." | wall
echo "Please finish and log off." | wall
sleep $sleeptime # Grace period
echo "All User Processes Now will be killed"
killall # kill all non-shutdown processes
sync
The line: /etc/umount /dev/rgb0e
unmounts the file system /dev/rgb0e and sends
all diagnostics to /dev/null.
# Bring the system down gracefully and ruthlessly.
# Read in minutes till shutdown.
echo "Minutes till shutdown? (0-15): "
read num
sleeptime=`expr $num \* 60` # seconds
echo "UNIX will shutdown in $num $min." | wall
echo "Please finish and log off." | wall
sleep $sleeptime # Grace period
echo "All User Processes Now will be killed"
killall # kill all non-shutdown processes
sync
echo " Unmounting the file systems"
/etc/umount /dev/rgb0e 2>/dev/null
The line: init s
changes the system level to single-user mode
in which the power may be turned off.
# Bring the system down gracefully and ruthlessly.
# Read in minutes till shutdown.
echo "Minutes till shutdown? (0-15): "
read num
sleeptime=`expr $num \* 60` # seconds
echo "UNIX will shutdown in $num $min." | wall
echo "Please finish and log off." | wall
sleep $sleeptime # Grace period
echo "All User Processes Now will be killed"
killall # kill all non-shutdown processes
sync
echo " Unmounting the file systems"
/etc/umount /dev/rgb0e 2>/dev/null
echo "Entering Single User Mode"
init s
If during the shutdown process you wanted the system
administrator to reaffirm his or her intention to shutdown,
the if statement to place in the /etc/shutdown file
would be:
$PROMPT$read yn # read reply
then
if
That is correct!
You've got it on the 2nd try.
Good, you understand the concept.
No, try test ... or [ "$yn" = ..]
No, try test "..." = "y" ... or [ "$yn" = ...]
You will be helped this time.
FORGET1
if [ "$yn" = "y" ]
Observe the result on the terminal.
$PROMPT$