Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # Precondition: `export PROMPT_COMMAND="history -a"` in .bashrc for ubuntu user
  4.  
  5. set -eux
  6.  
  7. COMMAND_TIME=$(date -Is -r /home/ubuntu/.bash_history)
  8. NOW=$(date -Is)
  9.  
  10. if [[ $(date -d "$NOW" +%s) -lt $(date -d "$COMMAND_TIME +60 minutes" +%s) ]]; then
  11. echo "Less then 60 minutes after .bash_history. Keep power-on."
  12. exit 0
  13. fi
  14.  
  15. echo "60+ min after .bash_history. Shutdown after 10 seconds!"
  16. sleep 10
  17. echo "Shutdown NOW!"
  18. shutdown -h now
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement