温馨提示×

如何查看centos crontab

小樊
39
2026-10-26 20:47:06
栏目: 智能运维

在 CentOS 中查看 crontab(定时任务)通常有以下几种方式,根据你查看的是当前用户还是系统级任务来区分:


一、查看当前用户的 crontab

crontab -l
  • 列出当前登录用户的定时任务
  • 如果提示 no crontab for user,说明该用户没有任务

二、查看指定用户的 crontab(需要 root 权限)

crontab -l -u username

例如:

crontab -l -u root

三、查看系统级 cron 任务

CentOS 中系统级的定时任务通常在以下目录:

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

四、查看 cron 服务状态

systemctl status crond

或

service crond status

启动 / 重启 cron:

systemctl start crond
systemctl restart crond

五、查看 cron 执行日志(排错用)

CentOS 7+:

journalctl -u crond

或

grep CRON /var/log/cron

如果你愿意,可以告诉我:

  • 你是 root 还是普通用户
  • 想看 某个用户 还是 系统任务

我可以给你更精确的命令。

0 踩