Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    what happens if SSH connection is lost when copying files between dir?

    Hi there,

    i m trying to copy some directories from one hard disk to another on the server(because running out of iNode). The files to be copied have very complex tree structure(thousands of sub-directories with more than 20 layers and files at he end nodes), which causes the size counting and copy process very very slow.

    i m doing the job by SSH to the server, firing a cp -R command. The problem is that the connection has a time limit, to keep the connection alive i can't just leave it there, i have to do something every few minutes, like press the enter key. During the waiting i usually do other things, but sometimes i forgot to press the enter key(or other network issue), hence connection gets lost!

    i m wondering if the copy command is still running. I used a 'watch' to view the change of the hard disk iNode after re-login to the server:
    watch -n1 df -i
    it shows the destination hard drive keeps changing the available and used iNode amount.

    Can someone tell me, when the ssh connection is down, is the cp command still running until all files are copied? And if there's a better way to do the job?

    Thanks for your help in advance! Cheers!

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    If the ssh connection is lost, then the cp is also broken.

    Use rsync.
    You must always face the curtain with a bow.

  3. #3
    Quote Originally Posted by Irithori View Post
    If the ssh connection is lost, then the cp is also broken.

    Use rsync.
    Thanks for your reply. It looks like that the cp is not broken when the connection is lost, because the iNodes figures IFree and IUsed keep changing after i re-ssh to the server, but it's still better to use rsync to ensure that all files are copied. Thanks!

  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts