0

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?

quantixed
  • 287
  • 3
  • 12
  • 1
    Have you tried adding zsh to Full Disk Access, or alternatively use /bin/sh in the shebang assuming your script conforms to sh? Even though the default shell has been changed in macOS, bash is still available and can be used at present. – TheDarkKnight Feb 21 '20 at 10:58

2 Answers2

0

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.

quantixed
  • 287
  • 3
  • 12
0

I had the same issue as @quantixed on Monterey but for me, dragging /bin/zsh into the Full Disk Access list, like @TheDarkKnight suggested, made launchctl run the script like it should.