2017-06-20 148 views
0

我運行兩個腳本的nohup - 不打印所有日誌

# Script 1 
nohup sh {command} & 

和的nohup.out是詳細所有日誌(腳本1)

# Script 2 
nohup sh {command} > {log_path} 2>&1 & 

但僅nohup.out的有有限的日誌如下所示(對於腳本2),

## Script2 output 
    Shutdown message has been posted to the server. 
    Server shutdown may take a while - check logfiles for completion 

如何在nohup.out中使用腳本2格式生成所有日誌。

+1

Stack Overflow是編程和開發問題的網站。這個問題似乎與題目無關,因爲它不涉及編程或開發。請參閱幫助中心的[我可以詢問哪些主題](http://stackoverflow.com/help/on-topic)。也許[超級用戶](http://superuser.com/)或[Unix&Linux堆棧交換](http://unix.stackexchange.com/)會是一個更好的地方。 – jww

+0

我通常在[Unix&Linux Stack Exchange](http://unix.stackexchange.com/)上詢問我的shell/nohup問題。 – jww

+0

看起來像腳本2錯誤是重寫。嘗試刪除錯誤重定向並檢查。 – skanda

回答

1

如果你想有兩個文件(的nohup.out和{} log_path),你可以嘗試:

((nohup {command}) > >(tee {log_path}) 2> >(tee {log_path}))>> nohup.out 

命令行的第一部分解釋here

之後,你只需要重定向(追加)輸出到nohup.out