Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # 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
- fi
- echo "60+ min after .bash_history. Shutdown after 10 seconds!"
- sleep 10
- echo "Shutdown NOW!"
- shutdown -h now
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement