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

 

 

posted @ 2020-05-18 22:17  夏日的向日葵  阅读(922)  评论(0编辑  收藏  举报