Last active
March 8, 2024 10:58
-
-
Save oilbeater/80d9bcf34758d1e720197b7a04dea512 to your computer and use it in GitHub Desktop.
shut down when ssh idle for more than 5 minutes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# docker run --name=close --network=host --privileged --restart=always -d close:v0.0.1 | |
while true; do | |
if [ -f dump ]; then | |
rm dump | |
fi | |
timeout 5m tcpdump -nn tcp and port 22 and greater 44 -w dump | |
line_count=$(wc -l < dump) | |
if [ $line_count -gt 0 ]; then | |
rm dump | |
else | |
rm dump | |
shutdown -h now | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment