macos - launchctl git : command not found

标签 macos git command launchd

好的,我正在尝试使用 launchctl 在我的 github 帐户上设置自动提交。为此,我创建了一个执行 git 命令的 sh 文件和每 2 分钟执行一次 sh 的 plist 文件,但 plist 文件失败。 sh 在 plist 之外运行时运行良好

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

请帮忙

最佳答案

路径上没有 git。将 git exe 所在的路径添加到路径环境变量中。

关于macos - launchctl git : command not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11771933/

相关文章:

批处理脚本中的 windows comp 命令 : remove prompts

c++ - 这种关于 seekp 的看似奇怪的行为是否正确?

仅对一个文件的 Git pull 请求

git - 如果从 bitbucket 触发时它们发生了变化,我怎样才能让 Jenkins 只构建功能分支

git - 我怎样才能推送到一个git bundle

terminal - 找不到 Py.test 命令,但已安装库

python - 可调整大小的窗口命令 python-maya

android - 如何在 Mac 上运行 AVD 管理器

objective-c - OS X 辅助功能 - 如何将窗口一直带到最前面?

c - 为 Atlas (os-x, macports) 制作动态库