Bernd
Bernd

Reputation: 11493

Launchd script running but output is missing (Exited with code: 2)

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?

Upvotes: 5

Views: 4313

Answers (1)

Parag Bafna
Parag Bafna

Reputation: 22930

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.

Upvotes: 2

Related Questions