Skip to content

Instantly share code, notes, and snippets.

@charlestang
Created January 28, 2012 10:21
Show Gist options
  • Save charlestang/1693862 to your computer and use it in GitHub Desktop.
Save charlestang/1693862 to your computer and use it in GitHub Desktop.
This script is for OS X. It check if the ssh forwording process exists, if not, create one. It is created for adding to crontab.
#!/bin/bash
listen=`netstat -f inet -p tcp -nRa | grep 'LISTEN' | awk '{ print $4 }' | grep 10024`
if [ $listen ]; then
if [ $listen = '127.0.0.1.10024' ]; then
exit
fi
fi
nohup ssh -ntt -D 10024 user@yourdomain.com > /dev/null 2>&1 &
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment