水平有限,不当之处欢迎指正
#!/bin/bash
#author wdll
#email gqoyvf@163.com
#version 1.0
#date 2019-7-2
export LANG="en_US.UTF-8"
function restart()
{
echo "服务地址为 $s_addr,是否要重启?"
read -p '输入y确定' choose
choose=`echo $choose| tr '[a-z]' '[A-Z]'`
if [[ $choose="Y" ]];then
if [[ $s_progess ]];then
echo "要杀进程了…………"
kill -9 $s_progess
sleep 2
fi
cd $s_addr/servers
rm -rf `find ./ -type d -name "cache"`
rm -rf `find ./ -type d -name "data"`
rm -rf `find ./ -type d -name "logs"`
rm -rf `find ./ -type d -name "tmp"`
sleep 2
cd $s_addr/
rm -rf `find $s_addr -name "*.lok"`
sleep 2
echo "正在重启中………………"
cd $s_addr/bin
# rm -rf ./*nohup.out
sleep 2
export this_date=`date +%Y%m%d_%H%M`
nohup ./startWebLogic.sh > ${this_date}_nohup.out &
sleep 2
tail -40f ./${this_date}_nohup.out
fi
}
read -p "输入要重启的端口号: " s_port
export s_progess=`lsof -i:$s_port|awk '{print $2}'|grep [0-9]|uniq`
#echo "进程号为 $s_progess"
if [[ ! "$s_progess" ]];then
read -p "进程不存在,请输入服务地址:" s_addr
restart
else
export s_addr=`pwdx $s_progess|awk '{print $2}'`
echo "进程号为 $s_progess"
restart
fi