执行. plist 文件 Path 时出错,所有权/权限不正确

terminal中执行 plist文件时出错

错误: Path had bad ownership/permissions

1)我使用 xcode 6创建了一个 plist 文件,并将 plist 文件保存在路径 library/launchdaemons/myfile.plist

Myfile 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>Label</key>
<string>myfile</string>
<key>ProgramArguments</key>
<array>
<string>/Desktop/myscript.sh</string>
</array>
<key>StartCalendarInterval</key>
<array>
<dict>
<key>Hour</key>
<integer>14</integer>
<key>Minute</key>
<integer>35</integer>
</dict>
</array>
</dict>
</plist>

2)在终端我使用 sudo launchctl load命令加载 plist文件

sudo launchctl load /library/launchdaemons/myfile.plist

3)之后我得到了这个错误

/Library/LaunchDaemons/myfile.plist: Path had bad ownership/permissions

我哪里做错了?

66350 次浏览

尝试更改. plist 文件的所有权:

sudo chown root /Library/LaunchDaemons/myfile.plist
sudo chgrp wheel /Library/LaunchDaemons/myfile.plist

或者更简单地说,在一个命令中更改用户和组:

sudo chown root:wheel /Library/LaunchDaemons/myfile.plist

同样值得注意的是,出于安全原因,这些根 LaunchDaemons不可能是全局可写的:

sudo chmod o-w /Library/LaunchDaemons/*

Plist 文件必须由 root 和组轮拥有,只能作为所有者的 rw。 根号600

除上述外

sudo chmod 600 /directoryToFile/filename.plist

例如:

sudo chmod 600 com.backup.plist

或者

sudo chmod 600 /Library/LaunchDaemons/myfile.plist