本文主要是介绍关闭公网mysq的shell脚本,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
#!/bin/sh#添加mysql配置
sed -i '22c #server {' /usr/local/webserver/nginx/conf/nginx.conf
sed -i '23c # listen 3307;' /usr/local/webserver/nginx/conf/nginx.conf
sed -i '24c # proxy_connect_timeout 1s;' /usr/local/webserver/nginx/conf/nginx.conf
sed -i '25c # proxy_timeout 3s;' /usr/local/webserver/nginx/conf/nginx.conf
sed -i '26c # proxy_pass 10.0.0.33:3307;' /usr/local/webserver/nginx/conf/nginx.conf
sed -i '27c #}' /usr/local/webserver/nginx/conf/nginx.conf#kill进程
NAME=nginx
echo $NAME
ID=`ps -ef | grep "$NAME" | grep -v "$0" | grep -v "grep" | awk '{print $2}'`
#ID=`ps -ef | grep "$NAME"`
echo $ID
echo "---------------"
for id in $ID
do
kill -9 $id
echo "killed $id"
done
echo "---------------"#启动
/usr/local/webserver/nginx/sbin/nginx
echo "mysql公网关闭成功"
版本 二
#!/bin/sh
echo -e "\E[1;33m"
cat <<\EOF/\/\ //\\/\ //\\///\\\ /\/^ \ / ^\/ ^ ^ ^ / ^ ^ ^ \/ ^ ^ \ */ ^ ^ \/^ ^\ ^ ^ ^ ^ ^ ^ ____ ^ ^ \ /|\/ ^ ^ ^ \ ^ _\___________________| |_____^ ^ \ /||o\/ ^^ ^ ^ ^\ /______________________________\ ^ ^ \ /|o|||\/ ^ ^^ ^ ^ /________________________________\ ^ /|||||o|\
/ ^ ^ ^ ^ ^ ^ ||||||||||||||||||||||||||||||oooooooooo| |ooooooo |
ooooooooooooooooooooooooooooooooooooooooooooooooooooooooo__ _ _ ___ __ __ __ _ _ _ / _` | _ __ _ _ | |_ (_) __ _ _ _\ V V // _` | | ' \ \__, | | ' \ | +| | | _| | | / _` | | ' \\_/\_/ \__,_| |_||_| |___/ |_|_|_| \_,_| _\__| _|_|_ \__,_| |_||_|EOF
echo -e "\E[0m"
echo "高山仰止,景行行止.虽不能至,心向往之。"
sleep 1s
#显示绿色
#showGreen CONTENT
#CONTENT:显示的内容
showGreen()
{content=$1echo -e "\033[1;32m$content\033[0m"
}#添加mysql配置
sed -i '22c #server {' /usr/local/webserver/nginx/conf/nginx.conf
sed -i '23c # listen 3307;' /usr/local/webserver/nginx/conf/nginx.conf
sed -i '24c # proxy_connect_timeout 1s;' /usr/local/webserver/nginx/conf/nginx.conf
sed -i '25c # proxy_timeout 3s;' /usr/local/webserver/nginx/conf/nginx.conf
sed -i '26c # proxy_pass 10.0.0.33:3307;' /usr/local/webserver/nginx/conf/nginx.conf
sed -i '27c #}' /usr/local/webserver/nginx/conf/nginx.conf#kill进程
NAME=nginx
echo $NAME
ID=`ps -ef | grep "$NAME" | grep -v "$0" | grep -v "grep" | awk '{print $2}'`
#ID=`ps -ef | grep "$NAME"`
#echo $ID
echo -e "\E[1;32mok\E[0m ................................. \E[1;36m[已查询出全部进程]\E[0m"
sleep 1s
#echo "---------------"
for id in $ID
do
kill -9 $id
sleep 1s
echo -e "\E[1;32mok\E[0m ................................. \E[1;36m[已kill $id 进程]\E[0m"
done
#echo "---------------"
sleep 1s
#启动
/usr/local/webserver/nginx/sbin/nginx
echo -e "\E[1;32mok\E[0m ................................. \E[1;36m[mysql公网已关闭]\E[0m"
这篇关于关闭公网mysq的shell脚本的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!