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