what does launchd status 78 mean?? why my user agent not running??

坚强是说给别人听的谎言 提交于 2019-12-03 04:44:23

问题


I want to run a unison sync service running in the background whenever I login. But the status code of my agent is 78. I don't know why, I tried some fix posted online, but it just doesn't work.

What's the problem?? below is the plist file for my service.

<?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>syncmyproject</string>
    <key>StandardOutPath</key>
    <string>/var/log/syncmyproject.log</string>
    <key>StandardErrorPath</key>
    <string>/var/log/syncmyproject.log</string>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    <key>Debug</key>
    <true/>
    <key>EnableGlobbing</key>
    <true/>
    <key>ProgramArguments</key>
    <array>
      <string>/usr/local/bin/unison</string>
      <string>-auto</string>
      <string>-batch</string>
      <string>-repeat watch</string>
      <string>~/home/project</string>
      <string>~/project</string>
    </array>
</dict>
</plist>

回答1:


I read man launchctl, find 78 means function not implemented. It doesn't help much.

Finally I make it work, actually there were errors in the plist, I recommend to install the brew cask install launchcontrol, which is a gui tool for launchctl, it can help detect errors and trouble shooting.




回答2:


I found the error had to do with permissions. I was trying to redirect errors and logs to the /var/log directory which my user is not able to write to. Changing the path to something where my user had proper permissions to r+w fixed it.

Also, be careful when loading your LaunchAgents. Do not use sudo to load a plist if you are in the ~/Library/LaunchAgents directory.




回答3:


[Ran into this problem as well, so documenting what I've found]

"78" is the last exit code of the job you're running. From man launchctl:

With no arguments, list all of the jobs loaded into launchd in three columns. The first column displays the PID of the job if it is run- ning. The second column displays the last exit status of the job. If the number in this column is negative, it represents the negative of the signal which stopped the job. Thus, "-15" would indicate that the job was terminated with SIGTERM. The third column is the job's label. If [label] is specified, prints information about the requested job.

I.e. you need to read the documentation (or source code) for whatever job you're starting. (In my case, mysqld)

It's worth noting that "78" is mentioned as a standard exit code on Linux, indicating a configuration error. So take a look at your job configuration (and error logs?) to see if you have something misconfigured.




回答4:


Here's what caught me: In Mac OS X you can run shell-scripts from command-line even if there's "just the script" in the file. However, when you run them from launchd you have to tell which binary that should run the script. A suppose that when you run from command-line it just uses the shell you are currently in (in my case bash), but when running from launchd there is no "surrounding script". I added

#!/bin/sh

as the first line in the script file, and then it worked.




回答5:


Similar to above I was getting a status 78 because I had symlink in my script path. The fix was to use the absolute path.




回答6:


I got this error while trying to run mono to start a local webserver. Turns out the fix was to not use the mono path given by "which mono" (which is a symlink: /Library/Frameworks/Mono.framework/Versions/Current/Commands/mono) but the actual location of the exe (in my case /Library/Frameworks/Mono.framework/Commands/mono).



来源:https://stackoverflow.com/questions/34215527/what-does-launchd-status-78-mean-why-my-user-agent-not-running

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!