Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run SCP in background and monitor the progress

Tags:

linux

scp

nohup

I'm running an scp command in the background:

 nohup scp file.gz root@target-host:/root/ > nohup.out 2>&1

I entered the password - I hit ctrl-z to halt the command and restarted it with bg, and I can confirm that it's running by executing jobs. However, is there a way of monitoring the progress of the file transfer (i.e. if I would be running it without placing it in the background)?

Thank you.

like image 968
Tamas Avatar asked Oct 30 '12 21:10

Tamas


People also ask

Can you run scp in the background?

scp run in the backgroundif it prompts for password then enter password. To bring the process back to foreground you can use 'fg' command.

Can we use nohup with scp?

Through scp command you can securely copy files without using FTP software. “nohup” command is used to run Linux command in background. Let's know more about it. Through this command the entire process will start executing in background.

What is scp and what does this command do?

SCP is an acronym for Secure Copy Protocol. It is a command line utility that allows the user to securely copy files and directories between two locations usually between unix or linux systems.

How do you stop a scp process?

Background & Disown the Process Background the scp process ( Ctrl + Z , then the command bg .) Disown the backgrounded process ( disown ). Terminate the session ( exit ) and the process will continue to run on the remote machine.


2 Answers

You could use screen(1) or similar, instead of bg.

Then you can control-ad to detach and screen -d -r to reattach.

You can also log out and back in as needed, without losing the ability to reattach, so it's great over unreliable networks. It dates back to when people were doing Slip and PPP over modems, and before.

like image 152
user1277476 Avatar answered Oct 09 '22 06:10

user1277476


While running CentOS / Red Hat / Fedora, I simply use:

ps aux | grep scp

to check on the running scp processes. To see if they are doing anything, I like to use:

du -s -c -h *

If you are on AWS EC2, you can switch to the section Instances to monitor network and r/w operations on the boot volume. To see what additional drives are doing, switch to the Monitoring tab in the Volumes section and select a volume.

like image 25
user3284525 Avatar answered Oct 09 '22 04:10

user3284525