不知什么原因,近几个月服务器上的shadowsocks总是会莫名地掉线,只能再次登录开启一遍。于是写了一个shell脚本去保持运行。
# keep_ss.sh
#! /bin/bash
# keep_ss.sh
#! /bin/bash
count=$(ps -ef | grep shadowsocks | grep -v "grep" | wc -l)
if [ $count = 0 ]; then
# shadowsocks shutdown, run again
setsid /etc/init.d/shadowsocks start
echo "shadowsocks restart at $(date)" >> ss.log
fi
然后在crontab中添加例行任务,每10分钟运行一次脚本
01,11,21,31,41,51 * * * * root bash keep_ss.sh
# shadowsocks shutdown, run again
setsid /etc/init.d/shadowsocks start
echo "shadowsocks restart at $(date)" >> ss.log
fi
然后在crontab中添加例行任务,每10分钟运行一次脚本
01,11,21,31,41,51 * * * * root bash keep_ss.sh
Comments
Post a Comment