Trying to figure out why a launchd user agent won't run a bash script.

I'm trying to write a bash script that creates a couple of other shell scripts and loads them into launchd as user agents.


I'm stuck. Here's the current script: https://github.com/sethgoldin/davinci-resolve-postgresql-workflow-tools/blob/mac os-unified-tools/davinci-resolve-postgresql-workflow-tools-optimize-agent-macos/ macOS/automate-workflow.sh


Running the shell scripts inside

/backup
and
/optimize
manually works fine, but launchd just doesn't run them for some reason. Furthermore,
launchctl list
is showing the
backup
agent with an exit code of 0, but the
optimize
agent with an exit code of 127.


My hunch is that something is amiss down in the heredocs that create the launchd user agents, on lines 65-82 and 84-101.


Can any launchd gurus help me out?


I'm on macOS 10.12.6.

Posted on Mar 21, 2018 2:20 PM

Reply
Question marked as Top-ranking reply

Posted on Mar 22, 2018 8:40 AM

Hello Seth,

I suggest you try again with $HOME. Using "Users/$USER" is not correct. There is no guarantee that "Users/$USER" is a user's home directory. I'm not sure what was going on with the $HOME version, but I can assure you there is no problem with an absolute path. It sounds like you should be using the "Program" key instead of "ProgramArguments" since your executable doesn't have any arguments.

Similar questions

4 replies
Question marked as Top-ranking reply

Mar 22, 2018 8:40 AM in response to Seth Goldin

Hello Seth,

I suggest you try again with $HOME. Using "Users/$USER" is not correct. There is no guarantee that "Users/$USER" is a user's home directory. I'm not sure what was going on with the $HOME version, but I can assure you there is no problem with an absolute path. It sounds like you should be using the "Program" key instead of "ProgramArguments" since your executable doesn't have any arguments.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Trying to figure out why a launchd user agent won't run a bash script.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.