Configure launchd

You need to load the launch agent into launchd.

  1. Open Terminal
  2. Type cd ~/Library/LaunchAgents
  3. Type launchctl load -w local.jackson.testwrite.plist (assuming that is the name of your plist file)

This will load and persistently enable your plist. You can check if it is loaded with launchctl list


To debug this, you will want to enable redirection.

<key>StandardErrorPath</key>
<string>/tmp/local.job.err</string>
<key>StandardOutPath</key>
<string>/tmp/local.job.out</string>

I also placed my version of your script in /usr/local/bin and made sure it was executable with chmod a+x

The error I get is:

/usr/local/bin/writeout.sh: line 3: log.txt: Permission denied

So, you might want to send your echo command to $TMPDIR or another place that's writeable. It looks like the default path for launchd isn't one a user can write to (and probably for good reason).

But, doing launchd/launchctl by hand is rough. I highly, highly recommend using a tool like LaunchControl or Lingon. They provide the help and automation that makes me so much better at these scripts.

Using Launch Control - it quickly let me recreate your job, had all sorts of helpful hints, and most importantly knew to suggest redirection to debug the script exit / error condition.

enter image description here

With one click, it added the lines above to my plist file and offered to save it and reload the job for me.