温馨提示×

怎样列出debian定时器

小樊
35
2026-10-07 17:51:11
栏目: 智能运维

在 Debian(以及大多数现代 Linux 发行版)中,“定时器”通常指 systemd 定时器(systemd timers),也可以指传统的 cron 任务。下面分别说明如何列出它们。


一、列出 systemd 定时器(推荐方式)

1. 查看当前已启用的定时器

systemctl list-timers

常见输出示例:

NEXT                        LEFT          LAST                        PASSED   UNIT
Thu 2026-01-15 00:00:00    5h left       Wed 2026-01-14 00:00:00    18h ago  apt-daily.timer

2. 查看所有定时器(包括未激活的)

systemctl list-timers --all

3. 查看某个具体定时器状态

systemctl status apt-daily.timer

4. 查看定时器对应的服务

systemctl cat apt-daily.timer

二、列出 cron 定时任务

1. 当前用户的 cron 任务

crontab -l

2. 系统级 cron 任务

ls -l /etc/cron.d/
cat /etc/crontab

3. 按时间目录查看

ls -l /etc/cron.hourly/
ls -l /etc/cron.daily/
ls -l /etc/cron.weekly/
ls -l /etc/cron.monthly/

三、at 定时任务(一次性)

atq

四、小结

类型 查看命令
systemd 定时器 systemctl list-timers
用户 cron crontab -l
系统 cron /etc/crontab, /etc/cron.d/
一次性任务 atq

如果你是想排查某个任务为什么没执行,可以告诉我具体场景,我可以帮你分析。

0 踩