温馨提示×

如何停止debian定时器

小樊
43
2026-10-10 17:37:21
栏目: 智能运维

在 Debian 里“定时器”通常有两种常见含义,停止方式不同:


一、如果是 systemd 定时器(timer)

1. 查看已有定时器

systemctl list-timers

2. 停止某个定时器

sudo systemctl stop name.timer

3. 禁止开机启动(可选)

sudo systemctl disable name.timer

4. 如果想彻底不再运行

sudo systemctl mask name.timer

示例:

sudo systemctl stop apt-daily.timer
sudo systemctl disable apt-daily.timer

二、如果是 cron 定时任务

1. 编辑当前用户的 cron

crontab -e

删除或注释(#)相关行,保存退出即可。

2. 系统级 cron

检查以下目录:

/etc/cron.d/
/etc/cron.daily/
/etc/cron.hourly/
/etc/cron.weekly/
/etc/cron.monthly/

删除或重命名对应脚本:

sudo rm /etc/cron.daily/xxx

3. 停止 cron 服务(不推荐,会影响所有任务)

sudo systemctl stop cron
sudo systemctl disable cron

三、如果是 at 定时任务

atq          # 查看
atrm <任务号> # 删除

如果你能告诉我具体是哪个定时器(如 apt-daily.timer、logrotate、还是某个 cron 脚本),我可以给你更精确的操作命令。

0 踩