Create a gist now

Instantly share code, notes, and snippets.

@jackytang /tester.sh
Last active Aug 29, 2015

What would you like to do?
检查连接状态 */10 * * * * /root/tester >> /var/log/shadowsocks_watchdog.log 2>&1 0 1 * * * echo "" > /var/log/shadowsocks_watchdog.log
#!/bin/sh
LOGTIME=$(date "+%Y-%m-%d %H:%M:%S")
wget -4 --spider --quiet --tries=1 --timeout=3 www.google.co.jp
if [ "$?" == "0" ]; then
echo '['$LOGTIME'] No Problem.'
exit 0
else
wget -4 --spider --quiet --tries=1 --timeout=3 www.baidu.com
if [ "$?" == "0" ]; then
echo '['$LOGTIME'] Problem decteted, restarting shadowsocks.'
/etc/init.d/shadowsocks restart
else
echo '['$LOGTIME'] Network Problem. Do nothing.'
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment