Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to run a job with launchd which runs a shell script that creates a zip file I then backup.

I am receiving the error: 6/26/13 5:04:37.992 PM[162]: (com.ian.evernote[18163]) Exited with code: 1

Here is my launchd plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">


Here is my shell script:


sudo zip -r ~/Documents/evernote_backup /Users/user/Library/Containers/com.evernote.Evernote/Data/Library

The shell script runs fine from the terminal. What am I doing wrong?

share|improve this question
up vote 0 down vote accepted

You cannot execute sudo inside the script. Who's going to enter the password? Why do you need this in the first place? It looks like you are operating inside your home folder where you should have all the permissions you want.

There are two solutions.

  • You need elevated privileges

Make this job a launch daemon instead of an agent. Make sure you change the paths to absolute ones (~ will expand to the executing users home directory, which is / for launch daemons).

  • You're fine with standard privileges

Don't use sudo.

Also: As the script consists of a single line I'd suggest to drop the script and call zip directly:

share|improve this answer
I have sudo in the script because it doesn't zip without it. zip I/O error: Permission denied zip error: Could not create output file (/Users/user/Documents/ I tried your suggestion of calling it directly but now I get exited with code 15 where do I find out what these codes mean? Is there a reason for the ending line of <string>/usr/bin/zip</string> ? I also set the privileges on the .sh file to x for everyone so I dont know why I needed sudo at all. – ian Jun 27 '13 at 2:54
Got it to work had to make a folder just for the zip with write permission for everyone. – ian Jun 27 '13 at 3:23
I removed the last <string>/usr/bin/zip</string> line in the array. The pleasures of copy&paste. As for the error codes: they are usually documented in the man pages. Try man zip and you'll find: 15: zip was unable to create a file to write to – LCC Jun 27 '13 at 16:38
Thanks. I turned on debugging for launchd and finally figured it out. – ian Jun 27 '13 at 20:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .