LaunchDaemons is giving error 127

4.7k Views Asked by At

i have a problem when i run LaunchDaemons this is my .plist:

<?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.startup</string>
<key>ProgramArguments</key>
<array>
    <string>/Users/myuser/project/workspace/tomcat/run/tomcat-
   exp.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WatchPaths</key>
<array>
   <string>/Users/myuser/project/workspace/tomcat/log/exp.out</string>
</array>
</dict>
</plist>

and this is the error am getting, i have been trying to solve this issue for hours but no suceess :(

when i checked system log this is what i found:

16239 Dec 28 21:36:29 myyser MRT[1481]: Error: SMJobRemove: The 
operation couldn’t be completed. (CFErrorDomainLaunchd error 2.)
16240 Dec 28 21:36:29 myuser com.apple.xpc.launchd[1] 
(com.apple.mrt[1481]): Service exited with abnormal code: 2
16241 Dec 28 21:36:29 myuser com.apple.xpc.launchd[1] (com.apple.mrt): 
Service only ran for 0 seconds. Pushing respawn out by 10 seco      
nds.
2

There are 2 best solutions below

9
beshio On

Your plist looks running shell script. Exit code 127 is reported when command is not found, usually $PATH is not correct or just by typo.

Other than that, your plist looks ok though I have only used OnDemand, and I haven't run script. What I usually do to debug daemons is to run them from command line

# /bin/launchctl load /Library/LaunchDaemons/mydaemon.plist

and see debug messages by fprintf on shell. You can redirect your stdout by adding

<key>StandardOutPath</key>
<string>/var/log/mylog.log</string>

to your .plist. Does your daemon work w/o any issue when started by command line manually ?

See this link for exit codes of scripts of bash.

0
NME New Media Entertainment On

We also had the same problem with error 127. However in our case we tried to use a symbolic inside a plist file running a peerJs server which was causing the problem discussed here

Avoid using a symbolic link inside a launch daemon file and use real path to a specific file