内存优化
将脚本设置crontab任务,建议每几分钟执行一次
cleanmem.sh代码如下:
#!/bin/bash used=`free -m | awk ‘NR==2’ | awk ‘{print $3}’` free=`free -m | awk ‘NR==2’ | awk ‘{print $4}’` echo “===========================” >> /var/log/mem.log date >> /var/log/mem.log echo “Memory usage | [Use:${used}MB][Free:${free}MB]” >> /var/log/mem.log if [ $free -le 100 ] ; then sync && echo 1 > /proc/sys/vm/drop_caches sync && echo 2 > /proc/sys/vm/drop_caches sync && echo 3 > /proc/sys/vm/drop_caches echo “OK” >> /var/log/mem.log else echo “Not required” >> /var/log/mem.log fi
后台进程检查
将脚本设置crontab任务,建议每几分钟执行一次
check_mem.sh代码如下:
#!/bin/bash #检查shadowsocks if ps -ef|grep “shadowsocks”|grep -v “grep” then echo “shadowsocks is running!” `date` >> /var/log/check.log else echo “shadowsocks is topped!” `date` >> /var/log/check.log /usr/bin/python /usr/bin/ssserver -c /etc/shadowsocks.json -d start fi #检查锐速serverspeeder if ps -ef|grep “serverspeeder”|grep -v “grep” then echo “serverspeeder is running!” `date` >> /var/log/check.log else echo “serverspeeder is stopped!” `date` >> /var/log/check.log /serverspeeder/bin/serverSpeeder.sh start fi
文章评论