在 Debian(以及大多数 Linux 发行版)里,“定时器”通常指的是 systemd timer(系统定时器)。下面按常见需求说明如何暂停/停止/临时禁用定时器。
sudo systemctl stop your-timer.timer
这只会立即停止,但重启后可能还会自动启动。
sudo systemctl disable your-timer.timer
如果你想立即停止 + 禁止开机启动:
sudo systemctl disable --now your-timer.timer
sudo systemctl mask your-timer.timer
效果:
unmask恢复:
sudo systemctl unmask your-timer.timer
systemctl list-timers
systemctl status your-timer.timer
编辑 crontab:
crontab -e
在对应行前加 #:
# 0 * * * * /path/script.sh
sudo systemctl stop cron
sudo systemctl disable cron
| 需求 | 推荐命令 |
|---|---|
| 临时停一下 | systemctl stop xxx.timer |
| 不希望开机运行 | systemctl disable --now xxx.timer |
| 完全锁死 | systemctl mask xxx.timer |
| 不确定是不是 systemd | systemctl list-timers |
如果你能告诉我:
我可以给你更精确的一条命令。