记一次Mac上launchctl引发的问题

问题

在一次偶然打开终端,查看系统日志的时候,发现一直有sunlogin相关的打印输出,这不是早就卸载了的向日葵软件么!作为强迫症患者肯定不能容忍这多余的输出,一定要把它给干掉。

Apr 27 17:21:04 yehu com.apple.xpc.launchd[1] (com.oray.sunlogin.desktopagent[4783]): Service exited with abnormal code: 78
Apr 27 17:21:04 yehu com.apple.xpc.launchd[1] (com.oray.sunlogin.desktopagent): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Apr 27 17:21:07 yehu com.apple.xpc.launchd[1] (net.nutstore.osxapp.FinderSyncExtension.F055F76B-6518-424B-BF11-B6897DB9E562[4785]): Caller wanted oneshot behavior for pre-existing instance: caller = Finder
Apr 27 17:21:08 yehu Movist[4787]: DEPRECATED USE in libdispatch client: dispatch source activated with no event handler set; set a breakpoint on _dispatch_bug_deprecated to debug
Apr 27 17:21:14 yehu com.apple.xpc.launchd[1] (com.oray.sunlogin.helper[4791]): Service could not initialize: Unable to set current working directory. error = 2: No such file or directory, path = /Applications/SunloginClient.app/Contents/Helpers: 18B75: xpcproxy + 10762 [1415][12FD3425-7E9A-3682-AA90-CD352F64B968]: 0x2
Apr 27 17:21:14 yehu com.apple.xpc.launchd[1] (com.oray.sunlogin.helper[4791]): Service exited with abnormal code: 78
Apr 27 17:21:14 yehu com.apple.xpc.launchd[1] (com.oray.sunlogin.helper): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Apr 27 17:21:14 yehu com.apple.xpc.launchd[1] (com.oray.sunlogin.service[4792]): Service could not initialize: Unable to set current working directory. error = 2: No such file or directory, path = /Applications/SunloginClient.app/Contents/MacOS: 18B75: xpcproxy + 10762 [1415][12FD3425-7E9A-3682-AA90-CD352F64B968]: 0x2
Apr 27 17:21:14 yehu com.apple.xpc.launchd[1] (com.oray.sunlogin.service[4792]): Service exited with abnormal code: 78
Apr 27 17:21:14 yehu com.apple.xpc.launchd[1] (com.oray.sunlogin.service): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Apr 27 17:21:34 yehu com.apple.xpc.launchd[1] (com.oray.sunlogin.desktopagent[4803]): Service could not initialize: Unable to set current working directory. error = 2: No such file or directory, path = /Applications/SunloginClient.app/Contents/Helpers: 18B75: xpcproxy + 10762 [1415][12FD3425-7E9A-3682-AA90-CD352F64B968]: 0x2
Apr 27 17:21:34 yehu com.apple.xpc.launchd[1] (com.oray.sunlogin.desktopagent[4803]): Service exited with abnormal code: 78
Apr 27 17:21:34 yehu com.apple.xpc.launchd[1] (com.oray.sunlogin.desktopagent): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Apr 27 17:21:44 yehu com.apple.xpc.launchd[1] (com.oray.sunlogin.helper[4805]): Service could not initialize: Unable to set current working directory. error = 2: No such file or directory, path = /Applications/SunloginClient.app/Contents/Helpers: 18B75: xpcproxy + 10762 [1415][12FD3425-7E9A-3682-AA90-CD352F64B968]: 0x2
Apr 27 17:21:44 yehu com.apple.xpc.launchd[1] (com.oray.sunlogin.helper[4805]): Service exited with abnormal code: 78
Apr 27 17:21:44 yehu com.apple.xpc.launchd[1] (com.oray.sunlogin.helper): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.
Apr 27 17:21:44 yehu com.apple.xpc.launchd[1] (com.oray.sunlogin.service[4806]): Service could not initialize: Unable to set current working directory. error = 2: No such file or directory, path = /Applications/SunloginClient.app/Contents/MacOS: 18B75: xpcproxy + 10762 [1415][12FD3425-7E9A-3682-AA90-CD352F64B968]: 0x2
Apr 27 17:21:44 yehu com.apple.xpc.launchd[1] (com.oray.sunlogin.service[4806]): Service exited with abnormal code: 78
Apr 27 17:21:44 yehu com.apple.xpc.launchd[1] (com.oray.sunlogin.service): Service only ran for 0 seconds. Pushing respawn out by 10 seconds.

解决

去网上一搜,发现是Mac上的定时任务在作怪,即launchctl

launchctl 将根据plist文件的信息来启动任务。plist脚本一般存放在以下目录:
/Library/LaunchDaemons -->只要系统启动了,哪怕用户不登陆系统也会被执行
/Library/LaunchAgents -->当用户登陆系统后才会被执行

有一种解决方法是将定时任务关掉,但是我试了,不能解决问题。

launchctl unload -w /Library/LaunchDaemons/xxx.plist

既然是要执行定时任务,那么直接把plist脚本文件删掉不就行了么。于是就去/Library/LaunchDaemons/Library/LaunchAgents目录下,找到com.oray.sunlogin.*.plist相关的文件,删除

为了保险起见,先把它们移到别的文件夹,重启之后,没出什么问题,并且发现讨厌的日志输出没了,世界瞬间清净了~

参考

  1. Mac中的定时任务利器:launchctl
  2. A "com.apple.xpc.launchd[1]" procedure which is carried out every minute

你可能感兴趣的:(记一次Mac上launchctl引发的问题)