11

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.

Tamas
  • 10,953
  • 13
  • 47
  • 77
  • if you just want to see it doing somthing, try IOTop for IO monitoring and HTop for process monitoring. – Frank Thomas Oct 30 '12 at 21:33
  • 3
    I'd like to see the transfer rate and the time remaining - just as if I'd be running a normal SCP command. – Tamas Oct 30 '12 at 21:34

9 Answers9

8
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 -> Send job to background.

disown -h %1 -> this will let it run even when you log out of system

Aashutosh Kumar
  • 615
  • 9
  • 13
3

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.

user1277476
  • 2,871
  • 12
  • 10
3

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.

Rashad
  • 11,057
  • 4
  • 45
  • 73
2

You can use jobs command to check the processes.

For example jobs -l will list all running processes along with the process id. Refer this site for reference.

Tarang Bhalodia
  • 1,185
  • 11
  • 21
0

Maybe you can redirect STDERR to file and use tail -f to monitor it

0

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 serial modems.

user1277476
  • 2,871
  • 12
  • 10
0

You can use watch tail nohup.out for that

Fingashpitzzz
  • 169
  • 4
  • 20
0

You can use tail command to see the output from nohup.out. Just write down the following command on terminal.

tail -n 10 -f nohup.out

-n 10 tells the number of lines at the end of contents to display.

-f tells the command to follow the nohup.out. Display every content which will be written to the file after executing command.

Hassan Raza
  • 3,025
  • 22
  • 35
0

For me only using verbose mode will append something to nohup.out

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

After you can monitor using tail -f nohup.out

ucsky
  • 442
  • 6
  • 13