unixasynchronoussynchronizationaixunison

How i can use unison to sync file of folders with the latest modification time?


How can I use Unison to sync folders with the latest modification time of its file

Example :

folder_1/file.txt changed at 12:30
folder_2/file.txt changed at 12:35

I wanna execute ./unison to give me the following result: update file with regards to latest modification time so that the updated file folder_1/file.txt will became the same file as folder_2/file.txt.


Solution

  • You can't.

    Unison works by comparing both files with their last synchronized version. If both have changed, and the end result is not identical, they are marked as a conflict. Although in that case a merge program can be invoked to resolve the conflict, the modification time plays no role at all in the whole process.

    From the manual:

    Note that whether a path is updated has nothing to do with its last modification time—Unison considers only the contents when determining whether an update has occurred. This means that touching a file without changing its contents will not be recognized as an update. A file can even be changed several times and then changed back to its original contents; as long as Unison is only run at the end of this process, no update will be recognized.