I am rsyncing a file from src to dst across a network. I’m navigating the many rsync options on the Linux man page, and need some help please.
A process on the destination responds to "newly arrived" files coming from the source. E.g. suppose the source file has a modification time of two days ago, but rsync
didn't transfer for it until five minutes ago. I can detect that newly-arrived file based on its recent timestamp.
Therefore, I need this desired timestamp behavior:
- dst file modification timestamp should represent the time at which content was last added by rsync transfer.
- dst file modification timestamp should not change when rsync compares src and dst without transferring new content, i.e. when dst already matches src.
What rsync options provide this desired behavior?
-a
is to copy the timestamp of the original file to its copy. Do you want different timestamps? In that case why? Or should both the original file and the copy have a timestamp indicating when it was transferred?stat
or some similar tool to look not only at the modification time but also the change time, which will be updated at the transfer. It means that you can use the standard behavior ofrsync -a
. This works at least when using linux file systems.