#!/bin/bash
progress_path=/test
jar_name=example.jar
while :
do
p_pid=`ps -ef |grep $jar_name|grep -v grep |awk '{print $2}'`
if [ "$p_pid" == "" ]
then
cd $progress_path
t="`cat progress.dat`"
sed -i "s/\(startTime\).*/\1 = $t/g" conf/conf.properties
./start.sh
fi
sleep 5s
done
当程序停止后自动从progress.dat中读取参数赋值到conf/conf.properties中重新启动程序