让 Mac 每小时整点报时
用 LaunchAgent 定时调度系统自带的 say 命令,让 Mac 每小时整点语音报时。
保存一个 LaunchAgent 配置,用 StartCalendarInterval 设为第 0 分钟运行 /usr/bin/say,再用 launchctl 加载。
01命令
命令
$ cat > ~/Library/LaunchAgents/com.user.saytime.plist <<'EOF'
<?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.user.saytime</string>
<key>ProgramArguments</key><array>
<string>/usr/bin/say</string><string>The time is</string><string>$(date +%%I %%M)</string>
</array>
<key>StartCalendarInterval</key><dict>
<key>Minute</key><integer>0</integer>
</dict>
</dict></plist>
EOF
launchctl load ~/Library/LaunchAgents/com.user.saytime.plist02作用说明
launchd 是 macOS 原生的定时调度器,配合系统自带的语音合成命令 say 正好实现整点报时。放在用户级 LaunchAgent 里、用 StartCalendarInterval 设置每小时第 0 分钟触发,不需要 cron 也不需要管理员权限。如果想让报时内容包含当前时间,可以再包一层 shell 脚本。
03风险
!注意: Mac 处于睡眠状态时不会报时;想改播报内容或语音就编辑 ProgramArguments 数组,想彻底停用就卸载并删除该 plist。
04撤销
撤销
$ launchctl unload ~/Library/LaunchAgents/com.user.saytime.plist && rm ~/Library/LaunchAgents/com.user.saytime.plist05来源
- launchctl - control launchd agents依据: Documents loading LaunchAgent plists with launchctl and StartCalendarInterval scheduling.
- say - output text to speech依据: Documents the say command used as the scheduled program.
最后验证: 2026-09-18 · 分类: 媒体