Linux / Unix rsync: Delete Source File After Transfer

To delete the source file after a successful transfer using rsync, you can use the --remove-source-files option. For example:

 
rsync --remove-source-files source_file destination

This will transfer the file source_file to the destination and remove it from the source location after the transfer is complete. Note that the --remove-source-files option is only applied if the transfer was successful, so if the transfer fails, the source file will not be deleted.

Keep in mind that the --remove-source-files option can be dangerous, as it can cause data loss if used improperly. It is important to verify that the transfer was successful before using this option.

Leave a Comment