开发squid启动脚本

最近在弄squid,然后就用shell写了一个小小的squid的启动脚本

[root@localhost ~]# cat /etc/rc.d/init.d/squid
 
#!/bin/bash
 
#chkconfig:345 88 14
 
#used for squid start,stop,restart
 
 
 
. /etc/init.d/functions
 
act(){
 
 if [ `ps -ef|grep 'sbin/squid'|grep -v grep|wc -l` -eq 1 ];then
 
 action "squid is running!!!" /bin/true
 
 else
 
 action "squid is stopped!!!" /bin/false
 
 fi
 
}
 
 
 
case "$1" in
 
start)
 
/application/squid/sbin/squid -D
 
 act
 
 ;;
 
stop)
 
/application/squid/sbin/squid -k shutdown
 
act
 
 ;;
 
restart)?
 
 /application/squid/sbin/squid -k reconfigure
 
 act
 
 
 
 ;;
 
parse)
 
 /application/squid/sbin/squid -k parse
 
 ;;
 
check)
 
 /application/squid/sbin/squid -k check
 
 ;;
 
*) echo "Usage:$0 start|stop|restart|check|parse"
 
 ;;
 
esac

看看效果

QQ20151020172727

此条目发表在Shell分类目录,贴了标签。将固定链接加入收藏夹。