Created
November 20, 2012 13:46
-
-
Save charlestang/4118044 to your computer and use it in GitHub Desktop.
Build a ssh tunnel in the background and test the port every 30 seconds if tunnel gone away build again.
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 | |
while true ; do | |
listen=`netstat -f inet -p tcp -nRa | grep 'LISTEN' | awk '{ print $4 }' | grep 18080` | |
if [ -z $listen ]; then | |
nohup ssh -ntt -D 18080 user@domain.com > /dev/null 2>&1 & | |
fi | |
sleep 30 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment