用WatchPaths键启动Launchd.plist:如何设置最小间隔? [英] Launchd.plist with WatchPaths key: How to set a minimum interval?
本文介绍了用WatchPaths键启动Launchd.plist:如何设置最小间隔?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用WatchPath键为launchd.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.
launchd.plist可能看起来像这样:
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>
推荐答案
添加此属性.请注意,整数以秒为单位.
Add this property. Note that the integer is in seconds.
<key>ThrottleInterval</key>
<integer>3600</integer>
这篇关于用WatchPaths键启动Launchd.plist:如何设置最小间隔?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文