![](/img/trans.png)
[英]Process with output file descriptor redirected to pipe is writing on screen instead of pipe
[英]Background process's redirected output not showing in the file
當我將命令的輸出作為后台進程調用時,我在將命令的輸出重定向到文件時遇到問題。
spawner.sh user @ host“ ../.profile >> / dev / null 2>&1; runjobs SOMEJOB”> test.log&
spawner.sh腳本使用#!/ usr / local / bin / expect解釋器,並在遠程主機上生成一個新進程(SOMEJOB)並與其進行交互。 當我在此語句末尾刪除與號時,輸出將被寫入到test.log文件中。 但是,當我在后台(使用“&”號運行)時,我的日志文件為空。
男孩和女孩有什么想法嗎?
我在python腳本中遇到了同樣的問題,原來是python中的緩沖。
使用-u選項,如python -u </ dev / null >>文件2>&1並解決了我的情況。
其他腳本語言可能具有與python -u類似的選項
嘗試在Expect腳本中關閉stdout緩沖。
fconfigure stdout -buffering none
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.