SQUID service (2) "script"

" 1 "
In order to make SQUID service start, stop, restart and other operations more convenient, SQUID service scripts can be written and managed by CHKCONFIG and SERVICE tools.

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 is not running....."
$0 start & > /dev/null
echo "Starting squid....."
;;
reload)
$CMD -k reconfigure
;;
check)
$CMD -k parse
;;
*)
echo "Usage: $0 {start | stop | restart | check | status}"
;;
esac #Press
: wq to save and exit
" 3 "
and return to the terminal to perform the following operations:
chmod +x /etc/init.d/squid
chkconfig --add squid
chkconfig squid on
Thus. You can start, stop, restart, and reload the SQUID server through the SQUID script by adding the corresponding start, stop, restart, and reload parameters during execution.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325295802&siteId=291194637