Home  >  Q&A  >  body text

sync - Linux 如何保持两个文件夹内容一致

Linux 如何保持两个文件夹内容一致 ?

比如

~/dock1 ~/dock2

要保证完全一致 ...

软连接是不行的好像

伊谢尔伦伊谢尔伦2744 days ago1135

reply all(13)I'll reply

  • 高洛峰

    高洛峰2017-04-17 13:27:56

    If soft links don’t work, use hard links

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 13:27:56

    It can be done using hard links, but the operations are on the same storage block and hard links cannot cross zones.
    Using rsync+cron, you can achieve consistent and automatic synchronization of all contents in two files or even folders.

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 13:27:56

    If everything must be exactly the same (permissions, properties, modification date, etc.)

    dd if=/dev/null count=100 bs=1M of=somefile
    mkfs somefile
    mount somefile /some/dir
    mount somefile /another/dir
    

    It really depends on what you want to do

    reply
    0
  • Cancelreply