十里 avatar

十里

@okooo5km

6/28/2025, 11:00:04 PM

🧵我把老 Intel Mac mini 当服务器用,需要 frpc 内网穿透和一些自己写的终端程序开机自启。
发现 launchctl 就是 macOS 版的 systemctl!告别手动启动和 nohup,让服务管理变得优雅 ✨

https://t.co/6xKP665lht

下面👇一起看看使用方法🚀 https://t.co/42w0Ppfryb
1/5 launchctl 通过 plist 文件管理服务,核心是 Label 字段,这就是服务的唯一标识符。

比如 plist 里写 `<string>com.frpc.service</string>`,后续所有操作都用这个 Label 📋。我的 frpc 服务的完整 plist 配置如图。

代码可点击🔗 https://t.co/oQT7wKF12x 查看! https://t.co/eHo479zttO
2/5 关键命令解析(以 com.frpc.service 为例):

加载服务:
sudo launchctl bootstrap system /Library/LaunchDaemons/com.frpc.plist

启动/重启服务:

1️⃣强制启动:
  launchctl kickstart system/com.frpc.service

2️⃣先杀掉再启动(重启):
  launchctl kickstart -k system/com.frpc.service
3/5 重要!关于停止服务的误区:
❌ launchctl kill TERM system/com.frpc.service
→ 只是发信号给进程,如果设置了 KeepAlive,会立刻重启!
✅ 正确停止方式:

launchctl bootout system/com.frpc.service - 彻底停止并卸载

kill 更像"重启进程"而不是"关闭服务"🤔
4/5 日常管理命令速查:

查看状态:launchctl print system/com.frpc.service
查看所有服务:launchctl list | grep com.frpc
验证 plist:plutil -lint com.frpc.plist
实时日志:tail -f /var/log/frpc.log
禁用服务:launchctl disable system/com.frpc.service 📊
5/5 用了一段时间感觉比 screen + nohup 方案稳定太多!frpc 断线自动重连,自己的终端程序崩溃自动重启。
Mac mini 7x24 运行,内网穿透从未掉线 🚀
记住:Label 是服务身份证,所有操作都靠它!
Share
Explore

TwitterXDownload

v1.2.1

The fastest and most reliable Twitter video downloader. Free to use, no registration required.

© 2024 TwitterXDownload All rights reserved.