a guest Mar 21st, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- # Precondition: `export PROMPT_COMMAND="history -a"` in .bashrc for ubuntu user
- set -eux
- COMMAND_TIME=$(date -Is -r /home/ubuntu/.bash_history)
- NOW=$(date -Is)
- if [[ $(date -d "$NOW" +%s) -lt $(date -d "$COMMAND_TIME +60 minutes" +%s) ]]; then
- echo "Less then 60 minutes after .bash_history. Keep power-on."
- exit 0
- echo "60+ min after .bash_history. Shutdown after 10 seconds!"
- sleep 10
- echo "Shutdown NOW!"
- shutdown -h now
RAW Paste Data