Linux命令之nohup 和 重定向

用途:使運行的程序忽略SIGHUP。app

語法:nohup Command [ Arg ... ] [ & ]
描述:nohup 命令運行由 Command 參數和任何相關的 Arg 參數指定的命令,忽略全部掛斷(SIGHUP)信號。在註銷後使用 nohup 命令運行後臺中的程序。要運行後臺中的 nohup 命令,添加 & ( 表示「and」的符號)到命令的尾部。文檔

那麼若是須要重定向該怎麼辦?terminal

nohup ./start-dishi.sh > FILE  & 便可input

nohup的man文檔中說明了:it

  • If standard input is a terminal, redirect it from an unreadable file.
  • If standard output is a terminal, append output to 'nohup.out' if possible, '$HOME/nohup.out' otherwise.
  • If standard error is a terminal, redirect it to standard output.
  • To save output to FILE, use 'nohup COMMAND > FILE'.

就是說 默認會把標準錯誤 重定向到標準輸出。標準輸出默認是 nohup.out, 能夠加上‘ > FILE’ 重定向到自定義文件。後臺

相關文章
相關標籤/搜索