Skip to content

Commit 2b414af

Browse files
docs: add Mac 命令行设置定时睡眠 to AI-maintained tech notes (#1514)
* docs: add Mac 命令行设置定时睡眠 to AI-maintained tech notes * fix: replace incorrect shutdown -s with correct macOS sleep methods, fix footer structure * fix: correct macOS sleep methods - replace shutdown -s with pmset/date, fix footer structure * docs: add cancel single schedule workaround, remove unreliable sleep+sleepnow method * docs: clean version - add cancel single schedule, fix sleep+sudo pitfall, remove unreliable method --------- Co-authored-by: gh-pr-review[bot] <268385713+gh-pr-review[bot]@users.noreply.github.com>
1 parent 37616ce commit 2b414af

1 file changed

Lines changed: 60 additions & 1 deletion

File tree

Solutions/Other-AI-LLM_Maintained_TechNotes.md

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,68 @@ npx skills add https://github.com/wechatpay-apiv3/wechatpay-skills --yes
3939

4040
或手动将 Skill 目录复制到 `.cursor/skills/` 下。这种「结构化知识包 > 纯 prompt」的模式值得关注——本质上是 API 提供方主动为 AI 编程场景适配知识格式,比开发者自己写 system prompt 靠谱得多。
4141

42+
## Mac
43+
44+
### 命令行设置定时睡眠(pmset)
45+
46+
Mac 可以通过命令行设置定时睡眠,核心工具是 `pmset`
47+
48+
**方式一:指定绝对时刻**
49+
50+
```bash
51+
sudo pmset schedule sleep "MM/DD/YYYY HH:MM:SS"
52+
```
53+
54+
例如设置 2026 年 4 月 19 日凌晨 1:00 睡眠:
55+
56+
```bash
57+
sudo pmset schedule sleep "04/19/2026 01:00:00"
58+
```
59+
60+
查看已设置的定时计划:
61+
62+
```bash
63+
pmset -g sched
64+
```
65+
66+
取消所有定时计划:
67+
68+
```bash
69+
sudo pmset schedule cancelall
70+
```
71+
72+
`pmset` 不支持按索引取消单条计划,只能 `cancelall` 全部清除。要“取消某一条”,思路是先 cancelall,再把想保留的重新添加:
73+
74+
```bash
75+
sudo pmset schedule cancelall
76+
sudo pmset schedule sleep "04/20/2026 02:00:00" # 重新添加想保留的
77+
sudo pmset schedule wake "04/20/2026 08:00:00"
78+
```
79+
80+
**方式二:指定相对时间(N 分钟后)**
81+
82+
macOS 的 `shutdown` 命令没有 `-s`(sleep)选项,只能关机/重启。要用相对时间触发睡眠,可以让 `date` 算出绝对时刻再传给 `pmset`
83+
84+
```bash
85+
sudo pmset schedule sleep "$(date -v+60M '+%m/%d/%Y %H:%M:%S')"
86+
```
87+
88+
`-v+60M` 表示当前时间加 60 分钟,改数字即可调整。
89+
90+
> **注意**:网上常见的 `(sleep 3600 && sudo pmset sleepnow) &` 方案有坑——`sudo` 凭据默认 5 分钟过期,后台进程又没有 tty 交互输入密码,等 sleep 结束后 `sudo` 会直接报错,根本不会睡眠。所以**相对时间睡眠推荐用 `date` + `pmset schedule` 方式**
91+
92+
**对比**
93+
94+
| 方式 | 优点 | 缺点 |
95+
|---|---|---|
96+
| `pmset schedule sleep "日期"` | 精确到时刻,系统级调度 | 日期格式需手动拼 |
97+
| `pmset schedule sleep "$(date ...)"` | 支持相对时间,自动算时刻 | 命令稍长 |
98+
99+
**立即睡眠**`sudo pmset sleepnow`
100+
42101
---
43102

44-
*本文由AI大模型维护,持续更新中。最近更新时间:2026-04-16*
103+
*本文由AI大模型维护,持续更新中。最近更新时间:2026-04-19*
45104

46105
> 同步发文于我的[个人博客](https://blog.letmefly.xyz/),(AI)创作不易,转载经作者同意后请附上[原文链接](https://blog.letmefly.xyz/2026/04/16/Other-AI-LLM_Maintained_TechNotes/)~
47106
>

0 commit comments

Comments
 (0)