温馨提示×

怎样查看debian定时器状态

小樊
43
2026-10-16 13:03:38
栏目: 智能运维

在 Debian 系统中,“定时器”可能指以下几种常见情况,下面分别说明如何查看状态:


一、systemd 定时器(timer)

如果你使用的是 systemd timer(现代 Debian 默认),查看方式如下:

1. 查看所有定时器状态

systemctl list-timers

或:

systemctl list-timers --all

可看到下次执行时间、上次执行时间、所属 unit。

2. 查看某个具体定时器

systemctl status xxx.timer

例如:

systemctl status apt-daily.timer

3. 查看定时器是否启用

systemctl is-enabled xxx.timer
systemctl is-active xxx.timer

4. 查看定时器日志

journalctl -u xxx.timer
journalctl -u xxx.service

二、cron 定时任务

如果是 cron / crontab(传统方式):

1. 当前用户的定时任务

crontab -l

2. 系统级定时任务

ls -l /etc/cron.d/
cat /etc/crontab
ls /etc/cron.daily /etc/cron.hourly /etc/cron.weekly /etc/cron.monthly

3. cron 服务状态

systemctl status cron

三、anacron(不精确定时)

cat /etc/anacrontab
systemctl status anacron

四、at 一次性任务

atq

查看等待执行的 at 任务。


总结

类型 查看命令
systemd timer systemctl list-timers
cron crontab -l / /etc/crontab
anacron /etc/anacrontab
at atq

如果你能告诉我具体是 systemd timer 还是 cron,我可以给你更精确的命令示例。

0 踩