Why am I not able to run my startup script upon login? I’m using OS X Yosemite.  I’m trying to run an sh script upon login, but I’m having problems.  I created the following file in my /Library/LaunchAgents directory …

-rwxr-xr-x  1 root  wheel  604 Oct 19 09:24 eXist.plist


The contents of the file are as follows:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
    &lt;dict&gt;
        &lt;key&gt;Label&lt;/key&gt;
        &lt;string&gt;eXist&lt;/string&gt;
        &lt;key&gt;Program&lt;/key&gt;
        &lt;string&gt;/Applications/eXist-db/bin/startup.sh&lt;/string&gt;
        &lt;key&gt;RunAtLoad&lt;/key&gt;
        &lt;true/&gt;
        &lt;key&gt;UserName&lt;/key&gt;
        &lt;string&gt;root&lt;/string&gt;
        &lt;key&gt;StandardErorPath&lt;/key&gt;
        &lt;String&gt;/tmp/eXistDB.err&lt;/string&gt;
        &lt;key&gt;StandardOutputPath&lt;/key&gt;
        &lt;string&gt;/tmp/eXistDB.out&lt;/string&gt;
    &lt;/dict&gt;
&lt;/plist&gt;


However, nothing is getting run (at least no output files are getting generated) and I can’t figure out why.  I have verified the path exists.  How can I get my script to run upon login?

Edit:

To prove the path exists, here is the output when tryihng the path in the script versus what was suggested ...

Daves-MacBook-Pro-2:~ davea$ ls /Applications/eXist-db/bin/startup.sh 
/Applications/eXist-db/bin/startup.sh
Daves-MacBook-Pro-2:~ davea$ ls /Applications/eXist-db.app/Contents/Resources/eXist-db/bin/startup.sh
ls: /Applications/eXist-db.app/Contents/Resources/eXist-db/bin/startup.sh: No such file or directory
You made some mistakes in your plist:

/Applications/eXist-db/bin/startup.sh probably doesn't exist if you have installed eXist-db 2.2
A valid path is /Applications/eXist-db.app/Contents/Resources/eXist-db/bin/startup.sh

StandardErorPath and StandardOutputPath are no valid keys
Valid keys are StandardErrorPath and StandardOutPath

probably the root &lt;-&gt; launchd problem already addressed by patrix

the plist doesn't have to be executable


To start the app after logging in with your user simply add it to System Preferences -&gt; Users &amp; Groups -&gt; Your user -&gt; Login Items

To start eXist-db 2.0 at boot time and jetty after logging in your user you have to do the following:
If you haven't done this already, first enter:
sudo /Applications/eXist-db/tools/wrapper/bin/exist.sh install

to install a LaunchDaemon org.tanukisoftware.wrapper.eXist-db.plist in /Library/LaunchDaemons/. If you want to add a StandardErrorPath and StandardOutPath modify the file with sudo nano /Library/LaunchDaemons/org.tanukisoftware.wrapper.eXist-db.plist.
It should look like this finally:
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
&lt;plist version=&quot;1.0&quot;&gt;
&lt;dict&gt;
    &lt;key&gt;Disabled&lt;/key&gt;
    &lt;true/&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;org.tanukisoftware.wrapper.eXist-db&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;/Applications/eXist-db/tools/wrapper/bin/exist.sh&lt;/string&gt;
        &lt;string&gt;launchdinternal&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;RunAtLoad&lt;/key&gt;
    &lt;true/&gt;
    &lt;key&gt;StandardErrorPath&lt;/key&gt;
    &lt;string&gt;/tmp/org.tanukisoftware.wrapper.eXist-db.stderr&lt;/string&gt;
    &lt;key&gt;StandardOutPath&lt;/key&gt;
    &lt;string&gt;/tmp/org.tanukisoftware.wrapper.eXist-db.stdout&lt;/string&gt;
&lt;/dict&gt;
&lt;/plist&gt;

Load the daemon permanently with:
sudo launchctl load -w /Library/LaunchDaemons/org.tanukisoftware.wrapper.eXist-db.plist 

Now create a second file in ~/Library/LaunchDaemons/ named com.eXist.plist with nano. It should look like this finally:
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;!DOCTYPE plist PUBLIC &quot;-//Apple//DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;
&lt;plist version=&quot;1.0&quot;&gt;
&lt;dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;com.eXist&lt;/string&gt;
    &lt;key&gt;Program&lt;/key&gt;
    &lt;string&gt;/Applications/eXist-db/bin/startup.sh&lt;/string&gt;
    &lt;key&gt;RunAtLoad&lt;/key&gt;
    &lt;true/&gt;
    &lt;key&gt;StandardErrorPath&lt;/key&gt;
    &lt;string&gt;/tmp/com.eXist.stderr&lt;/string&gt;
    &lt;key&gt;StandardOutPath&lt;/key&gt;
    &lt;string&gt;/tmp/com.eXist.stdout&lt;/string&gt;
&lt;/dict&gt;
&lt;/plist&gt;

A StandardErrorPath and StandardOutPath was added.
Load the agent permanently with:
launchctl load -w ~/Library/LaunchAgents/com.eXist.plist

Done.

Don't forget to set your (or the) JAVA_HOME variable properly. If you use a newer eXist-db release (e.g. 2.2) you have to add at least /Contents/Resources/ to the paths of exist.sh and startup.sh in the plist (please check the proper paths by opening the app bundle.

Hint: Don't use TextEdit to modify the plists: otherwise the plist files might be malformed.