我的 crontab 日志文件在哪里?

sho*_*key 11 cron

我的 debian7 上没有 /var/log/cron ,没有 /var/log/cron.log ,我的 crontab 日志文件在哪里?

ls /var/log/cron*
ls: cannot access /var/log/cron*: No such file or directory
Run Code Online (Sandbox Code Playgroud)

tal*_*zin 15

我认为debian cron写日志/var/log/syslog
如果您的系统依赖于rsyslog或者syslogd您可以在检查并取消/etc/rsyslog.conf/etc/syslog.conf线路:

# cron.* /var/log/cron.log
Run Code Online (Sandbox Code Playgroud)

然后重启服务。

例如,如果您的系统依赖于systemd您可以使用以下命令进行检查:

journalctl _COMM=cron
Run Code Online (Sandbox Code Playgroud)

或者

journalctl _COMM=cron --since="date" --until="date"
Run Code Online (Sandbox Code Playgroud)

对于日期格式,您可以检查journalctl

  • 那`sudojournalctl --从昨天开始-u cron.service`呢?什么是“_COMM”? (2认同)

edd*_*eek 5

由于它没有标记为 debian 并且也出现在 fedora 搜索中,因此以下是如何检查最近的(基于 systemd 的)fedora:

\n\n
sudo systemctl status crond\n
Run Code Online (Sandbox Code Playgroud)\n\n

典型输出

\n\n
\xe2\x97\x8f crond.service - Command Scheduler\n   Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)\n   Active: active (running) since Sun 2019-09-29 16:09:21 CEST; 47min ago\n Main PID: 1167 (crond)\n    Tasks: 1\n   Memory: 2.8M\n      CPU: 948ms\n   CGroup: /system.slice/crond.service\n           \xe2\x94\x94\xe2\x94\x801167 /usr/sbin/crond -n\n\nSep 29 16:09:21 ncelrnd0216 systemd[1]: Started Command Scheduler.\nSep 29 16:09:21 ncelrnd0216 crond[1167]: (CRON) STARTUP (1.5.4)\nSep 29 16:09:21 ncelrnd0216 crond[1167]: (CRON) INFO (Syslog will be used instead of sendmail.)\nSep 29 16:09:21 ncelrnd0216 crond[1167]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 31% if used.)\nSep 29 16:09:21 ncelrnd0216 crond[1167]: (CRON) INFO (running with inotify support)\n
Run Code Online (Sandbox Code Playgroud)\n\n

all日志

\n\n
journalctl --unit crond -n all\n
Run Code Online (Sandbox Code Playgroud)\n