Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to move files from server1 to server2.

A producer on server1 will keep generating the files, and a consumer on server2 will keep processing them.

I can copy files using the following shell script:

rsync path/*.txt server2:/path

The extension of the files on the destination (server2) will be changed from .txt to .done once they are processed, so if I run the command again, the files will once again copied (and processed) to the destination.

Hence, I want to delete (or rename or move) the original files so that they won't be transferred again.

I am using rsync version 2.6.3, which does not have --remove-source-files option.

I am new to shell scripting, so please give an example.

share|improve this question
add comment

2 Answers

use rsync --remove-source-files option

from man rsync

--remove-source-files
This  tells  rsync  to  remove  from  the sending side the files
(meaning non-directories) that are a part of  the  transfer  and
have been successfully duplicated on the receiving side.

You can always perform a trial run with no changes made using --dry-run option and If you like output run the final command without --dry-runoption

for example:rsync --remove-source-files -options /path/to/src/ computerB:/path/to/dest and also take a look at this question before proceeding.

share|improve this answer
    
rsync version 2.6.3 does not have this option. I don't think I have permission to update rsync. –  atripathi Jan 14 '13 at 10:34
1  
You can use tee and process substitution for this. for eg: use find to find your files and use tee to send the output to both rsync and rm see this –  harish.venkat Jan 14 '13 at 11:14
add comment

According to the man-page, you should be able to use --remove-source-files for rsync

--remove-source-files

This tells rsync to remove from the sending side the files (meaning non-directories) that are a part of the transfer and have been successfully duplicated on the receiving side.

share|improve this answer
    
rsync version 2.6.3 does not have this option. I don't think I have permission to update rsync. –  atripathi Jan 14 '13 at 10:35
    
@prodigy2050 Hmm, I do not have an alternative for you in that case. –  Bernhard Jan 14 '13 at 10:59
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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