您的位置:首页 > 运维架构 > Linux

后台执行 scp

2016-12-10 18:53 381 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  linux command