1、安装了squid,搭建了代理服务器,安装情况如下:
[dm@safety-monitoring ~]$ /opt/squid_install/sbin/squid -v
Squid Cache: Version 3.5.19
Service Name: squid
configure options: '--prefix=/opt/squid_install/' '--enable-ssl' --enable-ltdl-convenience
[dm@safety-monitoring ~]$
2、每次登陆查看日志之类的管理很不方便,就编写脚本
-
[madm@safety-monitoring ~]$ cat server.sh
-
-
#!/bin/bash
-
#start squid server
-
start(){
-
/opt/squid_install/sbin/squid
-
}
-
-
#stop squid server
-
stop(){
-
/opt/squid_install/sbin/squid -k shutdown
-
}
-
-
reconfigure(){
-
/opt/squid_install/sbin/squid -k reconfigure
-
}
-
-
rotate(){
-
/opt/squid_install/sbin/squid -k rotate
-
}
-
-
#查看日志,转换时间格式,原来它是显示1970年1月1日到当前的时间,可以用date -d @数字串来转化;
-
access_log(){
-
#tail -f /opt/squid_install/var/logs/access.logyk |awk '{print srtftime("%F %T",$1),print $0}'
-
tail -f /opt/squid_install/var/logs/access.logyk |awk '{printf strftime("%F %T",$1);$1="";print $0}'
-
}
-
cache_log(){
-
tail -f /opt/squid_install/var/logs/cache.log
-
}
-
case "$1" in
-
start)
-
start
-
-
;;
-
-
stop)
-
-
stop
-
-
;;
-
-
restart)
-
-
stop
-
-
sleep 10
-
-
start
-
-
;;
-
-
reconfigure)
-
-
reconfigure
-
-
;;
-
-
rotate)
-
-
rotate
-
-
;;
-
-
access_log)
-
-
access_log
-
-
;;
-
-
cache_log)
-
-
cache_log
-
-
;;
-
-
*)
-
-
printf 'Usage: %s {start|stop|restart|reconfigure|rotate|access_log|cache_log }\n'
-
-
exit 1
-
-
;;
-
-
esac
-
-
[adm@safety-monitoring ~]$
-
;;
-
esac
3、加入alias,不用直接sh或者点来执行脚本了
[mcbadm@safety-monitoring ~]$ vim ~/.bash_profile
加入:
alias squid=/home/mcbadm/squid_server.sh
别人的脚本:
stop(){
ps -ef|grep
test|awk '{print $2}'|while read pid
#ps –ef |grep
app-web |grep –v grep |awk ‘{print $2}’ |xargs –i kill -9 {} 这一条脚本即可。——yk
do
kill -9 $pid
done
}
阅读(2487) | 评论(0) | 转发(0) |