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