summaryrefslogtreecommitdiff
path: root/upstart/cloud-log-shutdown.conf
diff options
context:
space:
mode:
Diffstat (limited to 'upstart/cloud-log-shutdown.conf')
-rw-r--r--upstart/cloud-log-shutdown.conf19
1 files changed, 19 insertions, 0 deletions
diff --git a/upstart/cloud-log-shutdown.conf b/upstart/cloud-log-shutdown.conf
new file mode 100644
index 00000000..278b9c06
--- /dev/null
+++ b/upstart/cloud-log-shutdown.conf
@@ -0,0 +1,19 @@
+# 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