10

Is there a way of tell rsync to stop whenever possible in a clean way? Two options:

  • tell rsync to stop transfering the current file, clean any temp file and exit;
  • or let rsync end the transfer of the current file and then stop.

By doing Ctrl + C it does stop mid-transfer and leaves the temporary files there, right?

Edit

Even if using --inplace? What would be the best course of action? I'm using rsync with --inplace and I have to go fast, how can I say “May be end with this file then quit, or quit now, but clean this file you were copying so you don't leave corrupt things (I don't care if it's removed, I can backup again later)” or something like that.

0
10

If you kill rsync with Ctrl+C it does stop it mid transfer but it will not keep any temporary files there unless running with the --partial option.

For those also interested in just pausing rsync, if you press Ctrl+Z it pauses the program. When you resume it by running fg or bg rsync will reiterate over the file that it didn't finish and continue downloading the rest of the files. To see all currently paused programs run jobs

About --inplace

The problem with --inplace is that it does not create a new file when updating data, it just writes to the existing one. If you press ctrl + c while running with --inplace and it is updating an existing file it will leave a half finished file without removing it. Also if you are syncing only new files and not updating existing ones then when you cut off a transfer (with ctrl + c) it will leave a half finished file that it won't remove. Just a note I would not recommend --inplace for OS files. You can really jack up some things (because they change frequently)

8
  • Okey, so ctrl + C is precisely “letting rsync close”, right? I mean, it doesn't stop abruptly, it just sends a message to rsync “Please, stop now” and rsync will stop the transfer, clean whatever he was doing and then quit by itself. In that case, that's perfect. With ctrl + Z the problem is that I want to shut down the computer because I've to go.
    – Manuel
    Jan 28 '16 at 19:56
  • @Manuel Yes correct. I can edit my answer around if you will mark it as correct?
    – c0deous
    Jan 28 '16 at 21:24
  • 1
    Good to know that ctrl + C is a clean way to stop it.
    – Manuel
    Jan 28 '16 at 22:57
  • What about --inplace, what would be the best course of action? I'm using rsync with --inplace and I have to go fast, how can I say “May be end with this file then quit, or quit now, but clean this file you were copying so you don't leave corrupt things (I don't care if it's removed, I can backup again later)”.
    – Manuel
    Feb 1 '16 at 17:05
  • @Manuel The problem with --inplace is that it does not create a new file when updating data, it just writes to the existing one. If you press ctrl + c while running with --inplace and it is updating an existing file it will leave a half finished file without removing it. Also if you are syncing only new files and not updating existing ones then when you cut off a transfer (with ctrl + c) it will leave a half finished file that it won't remove. I tested all this btw.
    – c0deous
    Feb 1 '16 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.