在 Ubuntu 里“定时器”分几种情况,暂停方式不一样,下面按常见场景说明:
一、systemd 定时器(timer,最常见)
如果你用的是 systemctl 管理的 .timer(比如 apt-daily.timer):
暂停(停止并禁用)
sudo systemctl stop xxx.timer
sudo systemctl disable xxx.timer
只是临时暂停(重启后恢复)
sudo systemctl stop xxx.timer
查看状态
systemctl status xxx.timer
✅ 说明:systemd 没有“pause”概念,只能 stop。
二、cron 定时任务
Ubuntu 默认用 cron 或 cronie。
暂停某个用户的 cron
crontab -e
把对应行 注释掉(加 #):
# 0 * * * * /path/script.sh
暂停整个 cron 服务
sudo systemctl stop cron
三、at 定时任务(一次性)
查看:
atq
删除(暂停):
atrm
四、sleep / 脚本里的定时器
如果是你写的脚本:
sleep 3600
只能:
Ctrl + C中断- 或
kill PID
五、GNOME 桌面定时器(如闹钟类)
如果是图形界面工具(如 GNOME Clocks):
- 直接在界面点 暂停 / 停止
总结
| 类型 | 暂停方式 |
|---|---|
| systemd timer | systemctl stop xxx.timer |
| cron | 注释 or 停服务 |
| at | atrm |
| 脚本 sleep | kill |
如果你能告诉我具体是哪一种定时器(比如服务名或截图),我可以给你精确命令。