V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Sample
V2EX  ›  macOS

macOS Ventura 13.1 添加开机后台运行失败,不停弹通知

  •  
  •   Sample · 2022-12-24 18:59:14 +08:00 · 1494 次点击
    这是一个创建于 461 天前的主题,其中的信息可能已经有所发展或是发生改变。

    系统

    macOS Ventura 13.1

    怎么添加的后台运行

    brew services start clash
    

    问题

    • 在系统「设置」中的「登录项」有出现
    • 但是 ps|grep clash 并没有发现 clash 启动,而且会弹出很多同样的通知,而且是不停的弹出,如下图

    之前做过什么

    进入过 Recovery 模式,并且执行过命令:

    csrutil disable
    

    后来又csrutil enable

    我已经重装系统了,但是还是有这个问题

    9 条回复    2023-01-03 12:11:59 +08:00
    Williamongh
        1
    Williamongh  
       2022-12-24 19:07:20 +08:00
    删除启动项
    Sample
        2
    Sample  
    OP
       2022-12-24 19:21:22 +08:00
    @Williamongh 但我想开机运行 clash 啊
    derek80
        3
    derek80  
       2022-12-24 22:51:03 +08:00 via iPhone
    @Sample 开机启动里添加应用啊
    Sample
        4
    Sample  
    OP
       2022-12-25 02:00:29 +08:00
    @derek80 「系统设置」中的开机启动只能添加 `/Applications` 下的应用,如何把 `/usr/local/bin` 下的命令行应用加入开机?
    weeei
        5
    weeei  
       2022-12-26 11:26:42 +08:00
    @Sample 做成后台服务:


    <?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.github.Dreamacro.clash</string>
    <key>Program</key>
    <string>/bin/sh</string>
    <key>ProgramArguments</key>
    <array>
    <string>/bin/sh</string>
    <string>/usr/libexec/clash-wrapper</string>
    </array>
    <key>ProcessType</key>
    <string>Background</string>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
    </dict>
    </plist>
    weeei
        6
    weeei  
       2022-12-26 11:28:11 +08:00
    clash-wrapper 的内容:

    #!/usr/bin/env sh

    set -e

    /usr/bin/clash -d /usr/etc/clash
    weeei
        7
    weeei  
       2022-12-26 11:29:25 +08:00
    加载服务:

    launchctl load -w /Library/LaunchDaemons/com.github.Dreamacro.clash.plist
    Sample
        8
    Sample  
    OP
       2022-12-26 20:30:07 +08:00
    @weeei 这些我知道,无论是系统级别的还是 ~/Library/Launch...下都出现我上面那些问题,我最后写了 shell 脚本把要开机的一些命令行打包一起手动启动了,这个我估计是新系统的问题,如果你是最新的 macOS 不妨试试。

    最后,感谢你的回答,有心了。
    ihwbunny
        9
    ihwbunny  
       2023-01-03 12:11:59 +08:00
    装个配置描述文件,参考: https://www.bilibili.com/video/BV15A411R71u
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2858 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 13:12 · PVG 21:12 · LAX 06:12 · JFK 09:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.