I am currently using a plist to run a shell script.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.name.set</string>
<key>Program</key>
<string>/Users/username_here/Desktop/simple.sh</string>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>5</integer>
<key>StandardErrorPath</key>
<string>/tmp/com.name.example.stderr</string>
<key>StandardOutPath</key>
<string>/tmp/com.name.example.stdout</string>
</dict>
</plist>
This works! But when I change the program name to be
<string>/Desktop/simple.sh</string>
it doesn't run the script. also ~/Desktop/simple.sh
does not work.
Is there a way to run the script without knowing the username and using an absolute path?
I am also getting this error message when I tail launchd.
com.apple.xpc.launchd[1] (com.name.example[8178]): Service could not initialize: 14F27: xpcproxy + 13421 [1402][AD0301C4-D364-31CE-8BA7-B5DBECE64D0A]: 0x2
Thanks!
As mentioned in that Mac launchd tutorial tutorial, this launch plist script does the following things: Runs a Unix shell script named /Users/al/bin/crontab-test.sh. Runs that script every minute, as given by the StartInterval tag.
Thus, if your job label is "com.apple.sshd", your plist file should be named "com.apple.sshd.plist". Label <string> This required key uniquely identifies the job to launchd .
Just looking at a few Mac launchd examples here, the MacOS launchd plist file for Spotlight is surprisingly simple: The only thing they're really doing there is using the KeepAlive tag.
Just looking at a few Mac launchd examples here, the MacOS launchd plist file for Spotlight is surprisingly simple: The only thing they're really doing there is using the KeepAlive tag. On the other hand, their ssh.plist file is much longer, and demonstrates several other pieces of the Mac plist vocabulary:
Using a shell as arg0 and giving it a path relative to the user's home folder works for me:
<key>ProgramArguments</key>
<array>
<string>zsh</string>
<string>-c</string>
<string>~/CLI/scripts/list_open_jira_tickets --skip=5297 > ~/CLI/tmp/open_jira_tickets.txt</string>
</array>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With