探索编程的乐趣
发现技术的无限可能

Java程序shell启动脚本

monitoring.sh

#!/bin/sh
 
#切换到目录
cd /root
date=`date`
 
#查询端口占用
ps -ef|grep -v grep|grep fund-0.0.1-SNAPSHOT.jar
 
# $? -ne 0 不存在 $? -eq 0存在 
if [ $? -ne 0 ]
then
    nohup java -jar fund-0.0.1-SNAPSHOT.jar >/dev/null 2>&1 &
    echo $date  ":=============== restart ===============" >> monitoring.log
else
    echo $date  ":=============== is normal ==============" >> monitoring.log
fi

未经允许不得转载:二进制探索 » Java程序shell启动脚本