Linux后台運行任務nohup和&


nohup的使用:

1.后台運行腳本,輸出默認重定向到當前目錄下nohup.out文件

nohup sh test.sh &

2、后台運行腳本,並將標准輸出和標准錯誤輸出到test.log文件

nohup sh test.sh >>test.log 2>&1 &

nohup sh test.sh &>test.log &

3.后台運行腳本,不記錄輸出信息,輸出到空設備文件

nohup sh test.sh &>/dev/null &

4.后台運行腳本,不記錄輸出信息,但是將進程號寫進pidfile.txt文件中

nohup sh test.sh &>/dev/null & echo $! >pidfile.txt

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM