如果有一个应用程序可以自行启动,那么最有效的查找位置是什么?有没有人有一个很好的完整列表,其中包含检查启动项、登录项、登录挂钩、Cron、内核扩展等的位置...
此时我忘记了这些文件夹/plist 文件的一半在哪里。我希望有人可以分享一个备忘单。
基本上,我正在寻找 Mac OS 自动启动应用程序或脚本的最常见位置的列表(例如:在登录时或按计划等)
几个月前我安装了一个程序,它有一个我安装的启动选项。后来,我决定删除该程序,但即使在我卸载它之后它似乎也留下了启动脚本或项目......并且它试图每隔几秒钟启动一次。
我怎样才能删除这个项目?
这是来自控制台的
$ com.apple.launchd[1] (com.jft.PdaNetMac[24476]): Exited with exit code: 1
$ com.apple.launchd[1] (com.jft.PdaNetMac): Throttling respawn: Will start in 10 second
Run Code Online (Sandbox Code Playgroud) 我尝试使用launchd按时更新Homebrew。我的 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>ms.liu.homebrew.update</string>
<key>UserName</key>
<string>LiuMS</string>
<key>ProcessType</key>
<string>Background</string>
<key>EnvironmentVariables</key>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/brew</string>
<string>update</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>20</integer>
<key>Minute</key>
<integer>0</integer>
</dict>
<key>StandardOutPath</key>
<string>/usr/local/logs/ms.liu.homebrew.update.out</string>
<key>StandardErrorPath</key>
<string>/usr/local/logs/ms.liu.homebrew.update.err</string>
</dict>
</plist>
Run Code Online (Sandbox Code Playgroud)
它确实以某种方式工作:我可以launchctl start ms.liu.homebrew.update手动执行以更新我的 Homebrew。但是,launchd 不会定期执行此服务:对 stdout 重定向到的文件的最后更改是两天前。
我试图获取有关此服务的信息,但一无所获:
> launchctl print user/%MyPID%/ms.liu.homebrew.update``
Could not find service "ms.liu.homebrew.update" in domain for uid: %MyPID%
Run Code Online (Sandbox Code Playgroud)
看起来我还没有成功加载我的服务。如何?我使用过,launchctl load但似乎已被弃用。手册页推荐引导程序:
> launchctl bootstrap user/%MyPID% %Path-to-plist%
> %Path-to-plist%: Service cannot load in …Run Code Online (Sandbox Code Playgroud) 我创建了一个 launchd .plist 文件,以便每小时运行一个 python 脚本。我最终编辑并随后删除了 .plist 文件(在 /Library/LaunchDaemons 中)......但不知何故,launchd 仍在尝试运行脚本......原始 .plist 正在调用的文件也不再存在(它是在 /usr/bin 中)。现在每 10 秒,launchd 仍在尝试运行脚本,失败并重新生成...
我尝试用 Lingon 解决这个问题......无济于事......有没有办法彻底终止这个过程?我也尝试注销并重新启动...
机器正在运行 10.5.8
就像是
$ macwatch dir_or_file cmd_to_execude_when_arg1_is_changed
在此期间我不必编写 XML。我知道/sf/ask/106101131/。它可以是launchd的包装器-我只想能够输入上述命令。
我已经阅读了launchd.plist手册页,launchd 是否应该接收“错过的”事件?,而launchd 似乎忽略了 Yosemite 上的 StartCalendarInterval但这些都没有让我诊断为什么我的 launchd 任务没有运行。
我有一个任务计划在每天 10:35 运行,通常我的笔记本电脑当时处于睡眠状态,因此在这些情况下应该在笔记本电脑唤醒时启动该任务(并在笔记本电脑唤醒时正常运行)。
我实际看到的是,该任务很少单独运行,我始终必须使用 运行它launchctl start com.arewesmallyet.update,尽管当我这样做时它运行良好(一次)。
launchctl list | fgrep -i arewe 给出:
- 0 com.arewesmallyet.update
Run Code Online (Sandbox Code Playgroud)
的输出launchctl print gui/501/com.arewesmallyet.update是:
com.arewesmallyet.update = {
active count = 0
path = /Users/camdennarzt/Developer/Bash/dot-files/Library/LaunchAgents/com.arewesmallyet.update.plist
state = waiting
program = /Users/camdennarzt/Developer/Ruby/script.sh
arguments = {
/Users/camdennarzt/Developer/Ruby/script.sh
}
working directory = /Users/camdennarzt/Developer/Ruby/arewesmallyet
stdout path = /Users/camdennarzt/Developer/Ruby/arewesmallyet/log/update.log
stderr path = /Users/camdennarzt/Developer/Ruby/arewesmallyet/log/update_err.log
global environment = {
PATH => /usr/bin:/bin:/usr/sbin:/sbin
}
inherited …Run Code Online (Sandbox Code Playgroud) 我读到如果在发生 launchd 事件时计算机处于睡眠状态,则 launchd 将在计算机唤醒时运行该事件。
我的问题是关于已关闭的计算机。如果在发生 launchd 事件时机器断电,launchd 是否应该在下一次开机时运行它?
我问是因为我创建了一个事件(代理?),每天上午 09:45 运行。但通常在那个时候机器是断电的。打开计算机电源后,我没有看到事件的输出(正在发送电子邮件)。所以我试图缩小范围,如果这是设计行为还是我搞砸了什么。
为什么我的配置 plist 文件没有使用 launchctl 作为服务加载?
我正在运行 OSX Yosemite,我已经阅读了这个关于使用 launchctl http://nathangrigg.net/2012/07/schedule-jobs-using-launchd/ 的优秀教程
我已经使用服务的配置创建了一个正确的 .plist 文件(我知道这是正确的,因为它几乎是我几年前创建的工作 plist 配置文件的副本)。我输入
launchctl load ~/Library/LaunchAgents/com.apple.myservice.plist
Run Code Online (Sandbox Code Playgroud)
并得到回应
~/Library/LaunchAgents/com.apple.myservice.plist: File exists
Run Code Online (Sandbox Code Playgroud)
这不是非常具有描述性,但我去打字
launchctl start com.apple.myservice
Run Code Online (Sandbox Code Playgroud)
并且没有输出,什么也没有发生。我也尝试使用
launchctl enable ~/Library/LaunchAgents/com.apple.myservice.plist
Run Code Online (Sandbox Code Playgroud)
我只是得到一个
Usage: launchctl enable <service-target>
Run Code Online (Sandbox Code Playgroud)
作为回应。
有人可以回复在 OSX Yosemite 上加载启动服务的正确语法吗?
我使用Apple 看似简单的文档创建了一个 LaunchDaemon 来运行我编写的 Node.js 脚本。
这是plist文件。它基本上是 Apple 文档中的复制粘贴,设置为每 300 秒运行一次:
<?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.wintr.eodemail</string>
<key>ProgramArguments</key>
<array>
<string>~/projects/eod_email/eod</string>
</array>
<key>StartInterval</key>
<integer>300</integer>
<key>StandardOutPath</key>
<string>/var/log/eod-email.log</string>
<key>StandardErrorPath</key>
<string>/var/log/eod-email.log</string>
<key>Debug</key>
<true/>
</dict>
</plist>
Run Code Online (Sandbox Code Playgroud)
这是我遇到的错误/var/log/system.log:
Jul 22 10:55:52 Nick-Cox com.apple.xpc.launchd[1] (com.wintr.eodemail[7097]): Service could not initialize: 14E46: xpcproxy + 13421 [1402][7D917364-B96E-3F93-B923-A89B5BF5736D]: 0x2
Run Code Online (Sandbox Code Playgroud)
我所做的:
我有 10.11 的全新安装。当我在我自己的管理员帐户中启动系统时,没有启用登录服务,也没有启用任何互联网或云帐户(例如,消息、Facetime、邮件、日历等),我在控制台上看到以下消息:
10/4/15 2:12:08.104 PM com.apple.xpc.launchd[1]:(com.apple.diagnostics_agent) This service is defined to be constantly running and is inherently inefficient.
希望我的问题对于比我拥有更多操作系统经验的人来说应该是一个简单的问题:如果 Apple 自己的操作系统承认它“本质上效率低下”,为什么还存在这项服务?如果它“本质上是低效的”,那么用户如何在不让其他服务翻转或在控制台上注册警告/错误的情况下禁用它?
注意,控制台中还有其他服务具有相同的消息,例如 AirPlayUIAgent:
10/4/15 2:12:08.097 PM com.apple.xpc.launchd[1]:(com.apple.AirPlayUIAgent) This service is defined to be constantly running and is inherently inefficient.
我不能确定,但我认为这也发生在优胜美地 - 即,我认为这不是 El Capitan 的特定问题。感谢帮助理解这些消息、功能和行为。也感谢帮助禁用或更改它们。