Search code examples
macossharersynclaunch-agent

LaunchAgent with WatchPaths on mounted network share


I've got a (Synology) network share which is mounted on a Mac mini 1. I would like this share to be synced to Mac mini 2:

  • When the content of a specified directory is changed
  • Besides that, it should sync every hour

I've created a rsync script and the following LaunchAgent:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>KeepAlive</key>
    <dict>
        <key>SuccessfulExit</key>
        <false/>
    </dict>
    <key>Label</key>
    <string>com.company.rsync</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Library/Scripts/rsync.sh</string>
    </array>
    <key>StartInterval</key>
    <integer>3600</integer>
    <key>WatchPaths</key>
    <array>
        <string>/Volumes/web/network_share/specified_directory</string>
    </array>
</dict>
</plist>

When I look at the rsync logfile it seems that it syncs every 30 seconds even though nothing is changed in the specified directory.

If I change the directory to a local directory (eg. /Volumes/Server HD 2/local_share) everything works fine.

So somehow the LaunchAgent is triggered every 30 seconds and I don't know how. I've also looked at hidden files inside the directory but these are also unchanged.

EDIT:

I thought this was a Synology bug where timestamps of files were changed to some date in 2040. But I switched to another Synology which is updated to the latest DSM which doesn't have this problem anymore. However, the problem still exists.

Verbose logging says:

total: matches=0 hash_hits=0 false_alarms=0 data=0


Solution

  • Still not sure what causes this behavior, but mounting the share with smb seems to have solved the issue.