文章中用到的application.sh 可参考:
https://blog.csdn.net/qq_32415063/article/details/105568986
#!/bin/bash
# 文件目录,应用程序包的地址
appDir=/appdata/spring-test
# 设置需要检测的文件路径
fileName=find . -name $appDir/*.jar
# 获取当前文件最后编辑时间戳
startTime=`stat -c %Y $appDir/$fileName`
# 循环检查文件更新时间
while true
do
changeTime=`stat -c %Y $appDir/$fileName`
if [ $lastTime -eq $startTime ];then
echo $(date) $appDir/$fileName 'not change'
else
startTime=$lastTime
echo $(date) $appDir/$fileName 'has been changed'
#重启脚本
sh $appDir/bin/application.sh restart
fi
# 检测间隔
sleep 5
done