在ssh腳本最上方添加source命令
source /etc/profile
BUILD_ID=dontKillMe nohup java -jar app.jar > nohup.out & 2>&1 &
注意:source /etc/profile 如果沒有缕允,沒有錯(cuò)誤但也不會(huì)執(zhí)行java進(jìn)程
增加 source /etc/profile 后不能直接使用nohup java -jar app.jar & 這時(shí)候Jenkins會(huì)打印app啟動(dòng)信息
在一臺(tái)服務(wù)器遠(yuǎn)程鏈接另一臺(tái)服務(wù)器的時(shí)候,即便是存在BUILD_ID=dontKillMe袖肥,必須使用source /etc/profile火欧,使其在B終端內(nèi)有效棋电,不然默認(rèn)還是A終端茎截,導(dǎo)致無法正常啟動(dòng)。