带有 WatchPaths 键的 Launchd.plist:如何设置最小间隔?
如何使用 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>
How would one set a minimum interval for a launchd.plist script with a WatchPath key?
For example, I want to run a script every time new files appear in a directory, but I would like it to only run once an hour at maximum.
The 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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加此属性。请注意,该整数以秒为单位。
Add this property. Note that the integer is in seconds.