Launchd.plist with WatchPaths key: how to set the minimum interval?

How to set minimum interval for launchd.plist script using WatchPath key?

For example, I want to run a script every time new files appear in the directory, but I would like it to run only once per hour at most.

Running launchd.plist might look something like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>Label</key>
  <string>org.me.pytag</string>
  <key>ProgramArguments</key>
  <array>
    <string>/Users/me/bin/pytag.py</string>
  </array>
  <key>WatchPaths</key>
  <array>
    <string>/Volumes/Data/Media/Video/Processing/Converted</string>
  </array>
  <key>StandardOutPath</key>
  <string>/dev/null</string>
</dict>
</plist>
+5
source share
1 answer

Add this property. Note that the integer is in seconds.

<key>ThrottleInterval</key>
  <integer>3600</integer>
+8
source

All Articles