20 lines
562 B
Plaintext
20 lines
562 B
Plaintext
# log shutdowns and reboots to the console (/dev/console)
|
|
# this is useful for correlating logs
|
|
start on runlevel PREVLEVEL=2
|
|
|
|
task
|
|
console output
|
|
|
|
script
|
|
# runlevel(7) says INIT_HALT will be set to HALT or POWEROFF
|
|
date=$(date --utc)
|
|
case "$RUNLEVEL:$INIT_HALT" in
|
|
6:*) mode="reboot";;
|
|
0:HALT) mode="halt";;
|
|
0:POWEROFF) mode="poweroff";;
|
|
0:*) mode="shutdown-unknown";;
|
|
esac
|
|
{ read seconds idle < /proc/uptime; } 2>/dev/null || :
|
|
echo "$date: shutting down for $mode${seconds:+ [up ${seconds%.*}s]}."
|
|
end script
|