/etc/crontab
我在我的 Linux 系统上添加了以下内容:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed
0 0 */1 * * root chmod +x /root/source/auto-renew.sh && /root/source/auto-renew.sh >> /root/source/auto-renew-cron.log 2>&1
但是,当我现在运行时crontab -l
,它没有显示这个 crontab 任务:
[root@iZm5e2jhfbrshckqh6qdbuZ cron.d]# crontab -l
45 6 * * * "/root/.acme.sh"/acme.sh --cron --home "/root/.acme.sh" > /dev/null
为什么crontab -l
不显示/etc/crontab
任务?
这是日志:
[root@iZm5e2jhfbrshckqh6qdbuZ cron.d]# journalctl -u crond
-- Logs begin at Wed 2024-11-20 15:32:06 CST, end at Wed 2025-01-01 13:54:30 CST. --
Nov 20 16:01:01 iZm5e2jhfbrshckqh6qdbuZ CROND[1444408]: (root) CMD (run-parts /etc/cron.hourly)
Nov 20 17:01:01 iZm5e2jhfbrshckqh6qdbuZ CROND[1486477]: (root) CMD (run-parts /etc/cron.hourly)
Nov 20 18:01:01 iZm5e2jhfbrshckqh6qdbuZ CROND[1528604]: (root) CMD (run-parts /etc/cron.hourly)
Nov 20 19:01:01 iZm5e2jhfbrshckqh6qdbuZ CROND[1570709]: (root) CMD (run-parts /etc/cron.hourly)
Nov 20 20:01:01 iZm5e2jhfbrshckqh6qdbuZ CROND[1612872]: (root) CMD (run-parts /etc/cron.hourly)
Nov 20 21:01:01 iZm5e2jhfbrshckqh6qdbuZ CROND[1655340]: (root) CMD (run-parts /etc/cron.hourly)
Nov 20 22:01:01 iZm5e2jhfbrshckqh6qdbuZ CROND[1697643]: (root) CMD (run-parts /etc/cron.hourly)
Nov 20 23:01:01 iZm5e2jhfbrshckqh6qdbuZ CROND[1739698]: (root) CMD (run-parts /etc/cron.hourly)
Nov 21 00:00:01 iZm5e2jhfbrshckqh6qdbuZ CROND[1781104]: (root) CMD (chmod +x /root/source/auto-renew.sh && /root/source/auto-renew.sh >> /root/source/auto-renew-cron.log 2>&1)
Nov 21 00:01:01 iZm5e2jhfbrshckqh6qdbuZ CROND[1781971]: (root) CMD (run-parts /etc/cron.hourly)
Nov 21 00:01:01 iZm5e2jhfbrshckqh6qdbuZ anacron[1781980]: Anacron started on 2024-11-21
Nov 21 00:01:01 iZm5e2jhfbrshckqh6qdbuZ anacron[1781980]: Normal exit (0 jobs run)
Nov 21 01:01:01 iZm5e2jhfbrshckqh6qdbuZ CROND[1824103]: (root) CMD (run-parts /etc/cron.hourly)
Nov 21 01:01:01 iZm5e2jhfbrshckqh6qdbuZ anacron[1824112]: Anacron started on 2024-11-21
Nov 21 01:01:01 iZm5e2jhfbrshckqh6qdbuZ anacron[1824112]: Normal exit (0 jobs run)
Nov 21 02:01:01 iZm5e2jhfbrshckqh6qdbuZ CROND[1866166]: (root) CMD (run-parts /etc/cron.hourly)
Nov 21 02:01:01 iZm5e2jhfbrshckqh6qdbuZ anacron[1866175]: Anacron started on 2024-11-21
Nov 21 02:01:01 iZm5e2jhfbrshckqh6qdbuZ anacron[1866175]: Normal exit (0 jobs run)
Nov 21 03:01:01 iZm5e2jhfbrshckqh6qdbuZ CROND[1908181]: (root) CMD (run-parts /etc/cron.hourly)
Nov 21 03:01:01 iZm5e2jhfbrshckqh6qdbuZ anacron[1908190]: Anacron started on 2024-11-21
Nov 21 03:01:01 iZm5e2jhfbrshckqh6qdbuZ anacron[1908190]: Will run job `cron.daily' in 50 min.
Nov 21 03:01:01 iZm5e2jhfbrshckqh6qdbuZ anacron[1908190]: Jobs will be executed sequentially
Nov 21 03:51:01 iZm5e2jhfbrshckqh6qdbuZ anacron[1908190]: Job `cron.daily' started
Nov 21 03:51:01 iZm5e2jhfbrshckqh6qdbuZ anacron[1908190]: Job `cron.daily' terminated
Nov 21 03:51:01 iZm5e2jhfbrshckqh6qdbuZ anacron[1908190]: Normal exit (1 job run)
Nov 21 04:01:01 iZm5e2jhfbrshckqh6qdbuZ CROND[1950218]: (root) CMD (run-parts /etc/cron.hourly)
Nov 21 05:01:01 iZm5e2jhfbrshckqh6qdbuZ CROND[1992303]: (root) CMD (run-parts /etc/cron.hourly)
Nov 21 06:01:01 iZm5e2jhfbrshckqh6qdbuZ CROND[2034382]: (root) CMD (run-parts /etc/cron.hourly)
Nov 21 07:01:01 iZm5e2jhfbrshckqh6qdbuZ CROND[2076636]: (root) CMD (run-parts /etc/cron.hourly)
Nov 21 08:01:01 iZm5e2jhfbrshckqh6qdbuZ CROND[2118744]: (root) CMD (run-parts /etc/cron.hourly)
Nov 21 09:01:01 iZm5e2jhfbrshckqh6qdbuZ CROND[2160824]: (root) CMD (run-parts /etc/cron.hourly)
Nov 21 10:01:01 iZm5e2jhfbrshckqh6qdbuZ CROND[2203126]: (root) CMD (run-parts /etc/cron.hourly)
Nov 21 11:01:01 iZm5e2jhfbrshckqh6qdbuZ CROND[2245206]: (root) CMD (run-parts /etc/cron.hourly)