通过在三个不同的位置运行launchctl load命令,我得到了相同的错误launchctl load,它们都没有工作:
sudo launchctl load /Library/LaunchDaemons/updates.novel.plist
sudo launchctl load /Library/LaunchAgents/updates.novel.plist
sudo launchctl load /Users/username/Library/LaunchAgents/updates.novel.plist下面是我的updates.novel.plist文件,请您看一看,让我知道有什么问题吗?谢谢
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>GroupName</key>
<string>admin</string>
<key>UserName</key>
<string>Username</string>
<key>Debug</key>
<true/>
<key>Label</key>
<string>updates.novel</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/AMPPS/php-5.3/bin/php</string>
<string>/Applications/AMPPS/www/files/allnovels/novel.php</string>
<string>--daemon</string>
</array>
<key>StandardErrorPath</key>
<string>/var/log/files/error.1.log</string>
<key>StandardOutPath</key>
<string>/var/log/files/error.2.log</string>
<key>RunAtLoad</key>
<true/>
<key>AbandonProcessGroup</key>
<true/>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>14</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
</dict>
</plist>发布于 2014-05-08 16:14:43
启动服务需要由拥有plist文件的用户启动。如果所有者不是root用户,则不能使用sudo启动服务。
此外,文件的权限必须拒绝对除所有者以外的所有用户的写访问。
最后,该文件必须是常规文件(而不是管道、套接字或其他任何文件)。
发布于 2015-05-20 23:34:11
在man launchctl中,我们可以读到:
请注意,每个用户配置文件(LaunchAgents)必须由加载它们的用户拥有。所有系统范围的守护进程(LaunchDaemons)都必须由root拥有.配置文件不能是组或世界可写的。这些限制是出于安全原因而实行的。
launchctl.c是这样检查的:
bool path_goodness_check(const char *path, bool forceload) {
if (forceload) {
return true;
}
if (sb.st_mode & (S_IWOTH|S_IWGRP)) {
fprintf(stderr, "%s: Dubious permissions on file (skipping): %s\n", getprogname(), path);
return false;
}
if (sb.st_uid != 0 && sb.st_uid != getuid()) {
fprintf(stderr, "%s: Dubious ownership on file (skipping): %s\n", getprogname(), path);
return false;
}
if (!(S_ISREG(sb.st_mode) || S_ISDIR(sb.st_mode))) {
fprintf(stderr, "%s: Dubious path. Not a regular file or directory (skipping): %s\n", getprogname(), path);
return false;
}
if ((!S_ISDIR(sb.st_mode)) && (fnmatch("*.plist", path, FNM_CASEFOLD) == FNM_NOMATCH)) {
fprintf(stderr, "%s: Dubious file. Not of type .plist (skipping): %s\n", getprogname(), path);
return false;
}
return true;
}换句话说,纠正.plist文件的所有权、权限或路径,或者强制加载(-F)。
https://stackoverflow.com/questions/23544736
复制相似问题