man nohup
nohup - run a command immune to hangups, with output to a non-tty
nohup就是不挂起的意思( no hang up)。
nohup command > myout.file 2>&1 &
在上面的例子中,
0 – stdin (standard input),1 – stdout (standard output),2 – stderr (standard error) ;
2>&1
是将标准错误(2)重定向到标准输出(&1),标准输出(&1)再被重定向输入到myout.file文件中。
在后台运行 scp
1.nohup scp user@server:path/file localpath
2.输入密码
3.按Ctrl+z挂起当前进程
4.使用命令bg让挂起的进程继续运行
compile_time=`date +%Y%m%d%H%M%S`
nohup scp /root/test/wars/test/$compile_time/*.war root@113.111.111.111:/root/softs/temp/wars > /root/myscript/test.out 2>&1
或
compile_time=`date +%Y%m%d%H%M%S`
nohup scp /root/test/wars/test/$compile_time/*.war root@113.111.111.111:/root/softs/temp/wars