Search code examples
macosshellzshlaunch-agent

LaunchAgent doesn't run shell script


Under macOS prior to Catalina I had a LaunchAgent that ran a shell script daily. After upgrading and switching to zsh it doesn't work. Things I've checked:

  1. shebang switched to zsh
  2. shell script can be executed manually from command line
  3. sh has full disk access under System Preferences > Security & Privacy
  4. plist is in ~/Library/LaunchAgents and starts automatically, so chown is OK

I added an error check to my plist:

<key>StandardOutPath</key>
<string>/path/to/file.out</string>
<key>StandardErrorPath</key>
<string>/path/to/file.err</string>

and this gives file.err that reads

zsh: can't open input file: /path/to/script.sh

file.out is empty. My script has permissions -rwxr-xr-x

What am I missing?


Solution

  • After suggestions from TheDarkKnight, I added full disk access for zsh - no success. Solution was to switch the shebang back to /bin/bash and gave Full Disk Access to bash. The script now runs fine.