Run SCP in background and monitor the progress

Tamas picture Tamas · Oct 30, 2012 · Viewed 30.6k times · Source

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.

Answer

user1277476 picture user1277476 · Oct 30, 2012

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.