Skip to content

Instantly share code, notes, and snippets.

@jim80net
Created October 15, 2022 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jim80net/be23439647bc0d182a18641bc79e373b to your computer and use it in GitHub Desktop.
Save jim80net/be23439647bc0d182a18641bc79e373b to your computer and use it in GitHub Desktop.
Shutdown idle EC2 jumpbox
#!/bin/bash
set -eu -o pipefail
[[ $(w | wc -l) -lt 3 ]] && {
echo "Nobody logged in"
sudo shutdown -hP +60 "Shutting down due to no active sessions"
} || {
echo "Users logged in" >/dev/null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment