标签:SQUID服务
“1”“2”
脚本内容如下:
#!/bin/bash
#chkconfig: 2345 90 25
#config: /etc/squid.conf
#pidfile: /usr/local/squid/var/run/squid.pid
#Description: Squid - Internet Object Cache.
PID="/usr/local/squid/var/run/squid.pid"
CONF="/etc/squid.conf"
CMD="/usr/local/squid/sbin/squid"
case "$1" in
start)
netstat -anpt | grep squid &> /dev/null
if [ $? -eq 0 ]
then
echo "squid is running"
else
echo "正在启动squid....."
$CMD
fi
;;
stop)
$CMD -k kill &> /dev/null
rm -rf $PID &> /dev/null
;;
status)
[ -f $PID ] &> /dev/null
if [ $? -eq 0 ]
then
netstat -anpt | grep squid
else
echo "Squid is not running"
fi
;;
restart)
$0 stop &> /dev/null
echo "正在关闭squid....."
$0 start &> /dev/null
echo "正在启动squid....."
;;
reload)
$CMD -k reconfigure
;;
check)
$CMD -k parse
;;
*)
echo "用法: $0 {start | stop | restart | check | status}"
;;
esac
#按:wq保存退出
“ 3 ”
返回到终端进行如下操作:
chmod +x /etc/init.d/squid
chkconfig --add squid
chkconfig squid on
这样一来。就可以通过SQUID脚本来启动,停止,重启,重载SQUID服务器了,方法是在执行时添加相应的start,stop,restart,reload参数。
标签:SQUID服务
原文地址:http://blog.51cto.com/11964387/2112920