在启动WebLogic时,先结束掉之前启动的进程再启动
# !/bin/sh
# 启动bin文件夹下的startWebLogic.sh时,里面仍有其他脚本,临时文件中得到的进程id是startWebLogic.sh进程的id,即父进程id
# 存放PID(父进程)文件的文件夹
pidPath="pid/"
if [ ! -x "$pidPath" ]; then
mkdir "$pidPath"
fi
# listener PID文件
listenerPidFile=$pidPath"listener.pid"
if [ -f "$listenerPidFile" ]; then
PID=`cat $listenerPidFile`
if [ -n "$PID" ]; then
kill -9 $PID
fi
fi
# 启动一个监听(里面有监听端口号,所以也要手动结束掉)
nohup java -cp WEB-INF/classes/ com.Listener>/dev/null 2>&1 &echo $! > $listenerPidFile&
# startWebLogic.sh PID(父进程)文件
pidFile=$pidPath"quick_trans.pid"
# 根据父进程id删除子进程
if [ -f "$pidFile" ]; then
PRID=`cat $pidFile`
if [ -n "$PRID" ]; then
ps -ef|awk '{if($3=='$PRID'){system("kill -9 "$2)} }'
fi
fi
# 启动WebLogic
nohup /root/home/Oracle/Middleware/user_projects/domains/base_domain/bin/startWebLogic.sh>/dev/null 2>&1 &echo $! > $pidFile&
注意:
1、执行脚本修改后,将文件转化成unix格式,否则报“syntax error: unexpected end of file”错误用vi或vim编辑器,在命令模式下输入:
:set fileformat=unix
:wq!
2、-bash: ./**.sh: Permission denied问题
chmod +x **.sh //授权