5

I am trying to execute a script about every minute using launchd

I added a new launchd job plist that looks like this

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.bpstatusboard.omnifocus</string>
    <key>ProgramArguments</key>
    <array>
        <string>/Users/me/script.sh</string>
    </array>
    <key>StartInterval</key>
    <integer>50</integer>
</dict>
</plist>

The job is executed with the given time interval and generates the following log.

Apr 19 15:27:58 MacBook com.apple.launchd.peruser.501[153] (com.bpstatusboard.omnifocus[89895]): Exited with code: 2

Problem: The script should update a file but it's not. It's working correctly when I launch it manually in terminal. I couldn't find more details on exit code: 2. Any idea what stops the script to execute correctly?

Bernd
  • 11,133
  • 11
  • 65
  • 98
  • Very hard to say without knowing anything about what's in the script; see [this previous answer](http://stackoverflow.com/questions/15990512/launchctl-minimal-working-example-with-python/15991343#15991343) for some troubleshooting options. – Gordon Davisson Apr 19 '13 at 14:39

1 Answers1

2

Exited with code: 2

2 ENOENT No such file or directory. A component of a specified pathname did not exist, or the pathname was an empty string.

Your script does not exist at /Users/me/script.sh.

Parag Bafna
  • 22,812
  • 8
  • 71
  • 144
  • 1
    Actually this is wrong.The script was found and executed. Some command in the script returned code 2. Had launchd not found the script it would have complained like this: Job failed to exec(3) for weird reason: 2 – LCC Mar 28 '15 at 07:26