Community!
社区!
I am trying to execute a simple script every 5 minutes on my OSX 10.7.4. It should run no matter a user is logged into the machine or not (aka in the background session)
我正在尝试在OSX 10.7.4上每5分钟执行一个简单的脚本。无论用户是否登录到机器上,它都应该运行(也就是后台会话)
Thus I created I com.me.script.plist in /System/Library/LaunchDaemons/
and loaded it via: launchctl -S background ./com.me.script.plist
and started it via: launchchctl start com.me.script
于是我创建了我com.me.script。plist in /System/Library/LaunchDaemons/并通过以下方式加载:launchctl -S background ./com.me.script。plist并通过:launchchctl start com.me.script启动它
It runs fine the first time. But it never runs again after my set interval of 300seconds!
它第一次运行得很好。但在我设定的300秒间隔之后,它再也不会运行了!
Do you guys have any advice as to why that could be? If I run it in the Aqua Session it works perfectly, however, that means it'll only run if a user is logged in. However, I'd really need it to start running before that... and continue to do so no matter if a user logs in/out or another user logs in/out.
你们有什么建议吗?如果我在Aqua会话中运行它,那么它就会运行得很好,但是,这意味着只有当用户登录时它才会运行。然而,我真的需要它在那之前开始运行……并继续这样做,无论用户登录/退出或另一个用户登录/退出。
Here's my plist:
这是我的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>LimitLoadToSessionType</key>
<string>Background</string>
<key>Label</key>
<string>com.me.script</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/php</string>
<string>/Sites/script/notifier.php</string>
</array>
<key>StartInterval</key>
<integer>900</integer>
</dict>
</plist>
2 个解决方案
#1
0
Im going to say the issue lies here:
我要说的是,问题就在这里:
<string>/Sites/script/notifier.php</string>
Did you mean to write the following?
你是想写下面的吗?
<string>/Users/username/Sites/script/notifier.php</string>
Starting your path with /
implied the path starts at the root of the drive, which OSX has no /Sites
directory on the root by default.
以/隐含的方式启动路径从驱动器的根开始,OSX默认在根上没有/Sites目录。
#2
0
I found my own mistake... StartInterval should be 300 and not 900 if I expect it to run every 5min. sorry, stupid.
我发现了自己的错误……开始间隔应该是300而不是900,如果我期望它每5分钟运行一次。对不起,愚蠢。
#1
0
Im going to say the issue lies here:
我要说的是,问题就在这里:
<string>/Sites/script/notifier.php</string>
Did you mean to write the following?
你是想写下面的吗?
<string>/Users/username/Sites/script/notifier.php</string>
Starting your path with /
implied the path starts at the root of the drive, which OSX has no /Sites
directory on the root by default.
以/隐含的方式启动路径从驱动器的根开始,OSX默认在根上没有/Sites目录。
#2
0
I found my own mistake... StartInterval should be 300 and not 900 if I expect it to run every 5min. sorry, stupid.
我发现了自己的错误……开始间隔应该是300而不是900,如果我期望它每5分钟运行一次。对不起,愚蠢。