我正在后台运行一个scp
命令:
nohup scp file.gz root@target-host:/root/ > nohup.out 2>&1
我输入了密码 - 按下ctrl-z
来停止命令,然后使用bg
重新启动它,并通过执行jobs
来确认它正在运行。然而,如果我不将其置于后台运行,是否有一种监视文件传输进度的方法?
谢谢。
nohup scp <file_name> user@<IP_Address>:<path>
nohup: ignoring input and appending output to 'nohup.out'
user@IP_address's password:
Ctrl+z
bg
disown -h %1
bg -> 将作业发送到后台运行。
disown -h %1 -> 这将使它在您退出系统时继续运行。
ps aux | grep scp
检查正在运行的scp进程。为了查看它们是否在工作,我喜欢使用:
du -s -c -h *
如果您正在使用 AWS EC2
,您可以切换到“实例”部分,监视启动卷上的网络和读写操作。要查看其他驱动器的情况,请切换到“卷”部分的“监控”选项卡并选择一个卷。
您可以使用tail
命令查看nohup.out的输出。只需在终端上输入以下命令即可。
tail -n 10 -f nohup.out
-n 10表示要显示内容末尾的行数。
-f告诉命令跟随nohup.out。执行命令后,显示写入文件的每个内容。
对我来说,仅使用详细模式才会将一些内容附加到nohup.out
文件中。
nohup scp -v file.gz root@target-host:/root/ > nohup.out 2>&1
在使用tail -f nohup.out
进行监控之后
watch tail nohup.out
来做到这一点。STDERR
重定向到文件并使用 tail -f
监视它。