cickStar
cickStar

Reputation: 119

LaunchDaemons is giving error 127

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.

Upvotes: 1

Views: 5129

Answers (3)

Fabien Aur&#233;jac
Fabien Aur&#233;jac

Reputation: 197

As of 2025, most of the time, when all the scripts are properly made, this error can still happen due to macOS security, and can be fixed by authorizing the proper programs, (i.e. for example zsh, mysqldump in my case) in in system settings->security and confidentiality->complete disk access.

Upvotes: 0

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

Upvotes: 1

beshio
beshio

Reputation: 804

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.

Upvotes: 3

Related Questions