当前位置: 代码迷 >> 综合 >> squid 服务启动脚本
  详细解决方案

squid 服务启动脚本

热度:14   发布时间:2024-01-09 05:52:03.0

本人是无所谓是不是系统服务启动,因搭建作为生产环境,所以还是作为系统服务启动,所以在网上找到一个代码简洁些,可以用的启动脚本

squid 安装路径是/usr/local/squid

#!/bin/bash # 
chkconfig: 345 61 61
# description: squid is a web cache server
# processname: squid
. /etc/rc.d/init.d/functions
case $1 in
"start") /usr/local/squid/sbin/squid -s
if [ $? == "0" ];then
echo "squid start ok"
else
echo "please check the log"
fi
;;
"stop") /usr/local/squid/sbin/squid -k shutdown
if [ $? == "0" ];then
echo "squid stop ok"
else
echo "please check the log"
fi
;;
"restart")
/usr/local/squid/sbin/squid -k shutdown
if [ $? == "0" ];then
/usr/local/squid/sbin/squid -s
if [ $? == "0" ];then
 echo "squid restart ok"
else
/usr/local/squid/sbin/squid -s
if [ $? == "0" ];then
 echo "squid restart ok"
else
echo "please check the log"
fi
fi
fi
;;
 *)
echo "Usage only start|stop|restart"
;;
esac

把这个文件放到/etc/init.d/目录下并命名为squid

chmod +x /etc/init.d/squid

chkconfig --add squid



如果出现squid 服务不支持 chkconfig

则去更改上面的  chkconfig: 345 61 61    这几个数字