Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Macos LaunchAgent不';不要运行shell脚本_Macos_Shell_Zsh_Launch Agent - Fatal编程技术网

Macos LaunchAgent不';不要运行shell脚本

Macos LaunchAgent不';不要运行shell脚本,macos,shell,zsh,launch-agent,Macos,Shell,Zsh,Launch Agent,在Catalina之前的macOS手下,我有一个每天运行shell脚本的LaunchAgent。升级并切换到zsh后,它无法工作。我检查过的东西: shebang切换到zsh shell脚本可以从命令行手动执行 sh在系统首选项>安全和隐私下具有完全磁盘访问权限 plist位于~/Library/LaunchAgents中,并自动启动,因此chown正常 我在plist中添加了一个错误检查: <key>StandardOutPath</key> <string>

在Catalina之前的macOS手下,我有一个每天运行shell脚本的LaunchAgent。升级并切换到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>
    
    StandardOutPath
    /路径/to/file.out
    标准错误路径
    /path/to/file.err
    
    这就给出了
    file.err
    ,其中

    zsh:无法打开输入文件:/path/to/script.sh

    file.out
    为空。我的脚本具有权限
    -rwxr-xr-x


    我遗漏了什么?

    根据黑暗骑士的建议,我为zsh添加了完整的磁盘访问-没有成功。解决方案是将shebang切换回/bin/bash,并为bash提供完整的磁盘访问权限。脚本现在运行正常。

    您是否尝试过将zsh添加到完整磁盘访问中,或者假设脚本符合sh,在shebang中使用/bin/sh?尽管macOS中的默认shell已经更改,但bash仍然可用,并且目前可以使用。