LaunchAgent 没有 运行 shell 脚本
LaunchAgent doesn't run shell script
在 Catalina 之前的 macOS 下,我有一个 LaunchAgent,每天 运行 一个 shell 脚本。升级并切换到 zsh 后,它不起作用。我检查过的东西:
- shebang 切换到 zsh
- shell 可以从命令行手动执行脚本
- sh 在“系统偏好设置”>“安全与隐私”下具有完整的磁盘访问权限
- plist 在
~/Library/LaunchAgents
中并且自动启动,所以 chown 可以
我在我的 plist 中添加了一个错误检查:
<key>StandardOutPath</key>
<string>/path/to/file.out</string>
<key>StandardErrorPath</key>
<string>/path/to/file.err</string>
这给出了 file.err
读取
zsh: can't open input file: /path/to/script.sh
file.out
为空。我的脚本有权限 -rwxr-xr-x
我错过了什么?
根据 TheDarkKnight 的建议,我为 zsh 添加了完整的磁盘访问权限 - 但没有成功。解决方案是将 shebang 切换回 /bin/bash 并将完整磁盘访问权限授予 bash。脚本现在运行良好。
在 Catalina 之前的 macOS 下,我有一个 LaunchAgent,每天 运行 一个 shell 脚本。升级并切换到 zsh 后,它不起作用。我检查过的东西:
- shebang 切换到 zsh
- shell 可以从命令行手动执行脚本
- sh 在“系统偏好设置”>“安全与隐私”下具有完整的磁盘访问权限
- plist 在
~/Library/LaunchAgents
中并且自动启动,所以 chown 可以
我在我的 plist 中添加了一个错误检查:
<key>StandardOutPath</key>
<string>/path/to/file.out</string>
<key>StandardErrorPath</key>
<string>/path/to/file.err</string>
这给出了 file.err
读取
zsh: can't open input file: /path/to/script.sh
file.out
为空。我的脚本有权限 -rwxr-xr-x
我错过了什么?
根据 TheDarkKnight 的建议,我为 zsh 添加了完整的磁盘访问权限 - 但没有成功。解决方案是将 shebang 切换回 /bin/bash 并将完整磁盘访问权限授予 bash。脚本现在运行良好。