好的,所以我正在尝试使用 launchctl 在我的 github 帐户上设置自动提交。为此,我创建了一个执行 git 命令的 sh 文件和一个每 2 分钟执行一次 sh 的 plist 文件,并且 plist 文件失败。在 plist 之外运行时 sh 运行良好
launchctl 日志是:
Aug 2 00:02:24 Caseys-iMac com.github.gitSync[9227]: /usr/bin/gitsync.sh: line 4: git: command not found
Aug 2 00:02:24 Caseys-iMac com.github.gitSync[9227]: /usr/bin/gitsync.sh: line 5: git: command not found
Aug 2 00:02:24 Caseys-iMac com.github.gitSync[9227]: /usr/bin/gitsync.sh: line 6: git: command not found
Aug 2 00:02:24 Caseys-iMac com.apple.launchd.peruser.501[123] (com.github.gitSync[9227]): Exited with code: 127
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>com.github.GitSync</string>
<key>Program</key>
<string>/usr/bin/gitsync.sh</string>
<key>ProgramArguments</key>
<array>
<string>gitsync.sh</string>
</array>
<key>RunAtLoad</key>
<true />
<key>StartInterval</key>
<integer>120</integer>
</dict>
</plist>
.sh 文件
#!/bin/bash
DATE=`date`
cd /Applications/Minecraft\ Server/
git pull origin master
git commit -a -m "Auto Sync - $DATE"
git push origin master
请帮忙