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