您现在的位置是:网站首页> 编程资料编程资料
一个监控Squid运行进程数并自动重启的简洁Shell脚本分享_linux shell_
2023-05-26
424人已围观
简介 一个监控Squid运行进程数并自动重启的简洁Shell脚本分享_linux shell_
复制代码 代码如下:
#!/bin/sh
while sleep 30
do
SquidNum=`ps -ef|grep squid|grep -v grep|wc -l`
#HttpNum=`netstat -an|grep 0.0.0.0:80|grep -v grep|wc -l` #80状态
if [ $SquidNum != 3 ] ; then
/etc/rc3.duid start
adddate=`date +%Y-%m-%d`" "`date +%H:%M:%S`
echo "$adddate squid started!" >> /home/resquid.log
fi
#超过5000个http请求就重启squid服务
HttpNum=`netstat -an|grep 80|grep -v grep|wc -l`
if [ $HttpNum -gt 5000 ] ; then
/etc/rc3.duid restart
adddate=`date +%Y-%m-%d`" "`date +%H:%M:%S`
echo "$adddate http out 5000 squid started!" >> /home/resquid.log
fi
done
您可能感兴趣的文章:
相关内容
- CentOS中使用Shell脚本实现每天自动备份网站文件和数据库并上传到FTP中_linux shell_
- 一个简洁的全自动安装LNMP服务器环境的Shell脚本分享_linux shell_
- Shell踢人的三种方法_linux shell_
- Linux Shell的一些使用小技巧收集_linux shell_
- CentOS下mysql定时备份Shell脚本分享_linux shell_
- Shell脚本实现上传zip压缩文件到FTP服务器_linux shell_
- Shell脚本查看网卡实时流量_linux shell_
- Shell脚本获取国内各大运营商网段脚本分享_linux shell_
- Shell中使用plink工具实现远程批量关机_linux shell_
- Shell脚本实现根据端口号kill相应进程功能_linux shell_
