ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
### Checks to see if SSH connection is up
### Configurable variables
### Recursive function to clean up the log file
if [ `cat $LOGLOCATION | grep ^ -c` -ge 500 ]
cat $LOGLOCATION | sed 1d > $LOGLOCATION
### If there are no instances, start one
if [ `ps ax | grep -c $RPORT` -lt 1 ]
echo "`date +"%F %T"` - SSH connection not found..." >> $LOGLOCATION
ssh -fNC -l $USER -i /home/$USER/.ssh/id_rsa -R $RPORT:localhost:$LPORT $HOST
echo "`date +"%F %T"` - SSH connection reestablished!" >> $LOGLOCATION
echo "`date +"%F %T"` - SSH connection found. No action taken." >> $LOGLOCATION
### Run the log cleaner