I killed a local "rsync -ah" process.
It left junk files like ".abc.vmdk.zxivMN" in the target directory.
The junk files do not get deleted on consecutive "rsync -ah" runs.

I ran diff on both folders I was syncing and it reported: "Only in /mnt/archive1/documents/general: .abc.vmdk.zxivMN"

What is the best way to clean up the temporary rsync files ?

4 Answers 4


Tell rsync to delete files not on the source, with --delete-during or --delete-after. Be careful and use this option only if you don't have legitimate files on the target that aren't there on the source.

See man rsync.

Of course, you could always manually delete the files you detected with diff...

  • This is no good when you're doing a copy rather than a move. Sep 16, 2017 at 0:55

I do it using

find -type f -iname ".*.*.??????" -ls

for test and

find -type f -iname ".*.*.??????" -delete

for clear


I found the following command worked for me when trying to delete temp files left behind by rsync after a failed transfer.

find vod-content/ -path '*/.*' -print0 | xargs -0 -r rm -v

What this does is it finds all "hidden" files (files that begin with "." character) and passes them on to "rm" command to delete them.

A obvious known issue regarding the code above is if your contents contain hidden files then this command will delete those as well.


I'm looking for a better solution but the only one I can think of is to move all empty files starting with a ., and having two further dots in them, to a trash folder (using rm is a bit risky):

find -type f -empty -iname ".*.*.*" | xargs -n 1 -d'\n' mv -v -t /tmp/

By no means foolproof.


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.