Squid 服务随系统启动,因搭建作为生产环境,所以还是作为系统服务启动,所以在网上找到一个代码简洁些,可以用的启动脚本。
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 这几个数字