Created
October 31, 2012 01:49
-
-
Save iwinux/3984337 to your computer and use it in GitHub Desktop.
monitor SSH status
This file contains hidden or 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 | |
# usage: monssh [hostname] | |
if [[ -z $1 ]] | |
then | |
HOST="YOURHOST" | |
else | |
HOST=$1 | |
fi | |
CMD="ssh -fqND 9999 $HOST" | |
while true | |
do | |
pgrep -fl "$CMD" > /dev/null 2>&1 | |
if [[ $? -eq 0 ]] | |
then | |
echo "[`date`] Status: OK." | |
else | |
echo "Status: launching $CMD" | |
$CMD | |
fi | |
sleep 30 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@vietor 这个只要在
~/.ssh/config
设置就行了