6

如何使用 WatchPath 键为 launchd.plist 脚本设置最小间隔?

例如,我想在每次目录中出现新文件时运行一个脚本,但我希望它最多每小时只运行一次。

launchd.plist 可能看起来像这样:

<?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>
4

1 回答 1

8

添加此属性。请注意,整数以秒为单位。

<key>ThrottleInterval</key>
  <integer>3600</integer>
于 2010-07-18T04:10:45.187 回答