while true do ONE='one' ONE_FILE='./one/manage.war' ONE_TIME=$(stat -c %Y $ONE_FILE) ANOTHER='another' ANOTHER_FILE='./another/manage.war' ANOTHER_TIME=$(stat -c %Y $ANOTHER_FILE) if [ "$ONE_TIME" -gt "$ANOTHER_TIME" ] then FILE_NAME="$ONE_FILE" FOLD="$ONE" else FILE_NAME="$ANOTHER_FILE" FOLD="$ANOTHER" fi echo "最新的文件是${FILE_NAME}" echo "最新的文件夹是${FOLD}" # 先操作7002的端口 proc70021=$(pgrep -f "${ONE_FILE} --spring.profiles.active=prod --server.port=7002$") proc70022=$(pgrep -f "${ANOTHER_FILE} --spring.profiles.active=prod --server.port=7002$") if [ "$proc70021"x == "x" ] && [ "$proc70022"x == "x" ] ; then ./manageStart7002.sh $FOLD fi sleep 30 done