while true
do
    ONE='one'
    ONE_FILE='./one/wap.jar'
    ONE_TIME=$(stat -c %Y $ONE_FILE)

    ANOTHER='another'
    ANOTHER_FILE='./another/wap.jar'
    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}"

    # 先操作7006的端口
    proc70061=$(pgrep -f "${ONE_FILE}$")
    proc70062=$(pgrep -f "${ANOTHER_FILE}$")
    if [ "$proc70061"x == "x" ] && [ "$proc70062"x == "x" ] ; then
        ./wapStart7006.sh $FOLD
    fi

    # 再操作7016
    proc70161=$(pgrep -f "${ONE_FILE} --server.port=7016$")
    proc70162=$(pgrep -f "${ANOTHER_FILE} --server.port=7016$")
    if [ "$proc70161"x == "x" ] && [ "$proc70162"x == "x" ] ; then
        ./wapStart7016.sh $FOLD
    fi
    sleep 30
done