如果直接在終端啟動一個程序,那么終端關閉的時候,程序也會被終止,所以要使用nohup讓程序后臺執行
- 基本
nohup java -jar xxx.jar > xxx.log 2 > &1 &
注:
其中 0、1、2分別代表如下含義:
0 – stdin (standard input)
1 – stdout (standard output)
2 – stderr (standard error)
nohup ./startWebLogic.sh >out.log 2>&1 &
nohup+最后面的& 是讓命令在后臺執行
out.log 是將信息輸出到out.log日志中
2>&1 是將標準錯誤信息轉變成標準輸出,這樣就可以將錯誤信息輸出到out.log 日志里面來。
參考: