背景:购买的阿里云主机磁盘容量过小,不小心一下子顶满了。

删除一些东西后发现能正常使用,然后写个定时任务脚本,发现/var/log/cron 为空。其他的除开顶满外的日期之前有输入,其余都为空。

度娘半天,看尽各位大佬扯淡,终于在谷歌看到一篇文章解决问题。

$ vi /etc/rsyslog.conf


找到此行:#$ModLoad imklog # reads kernel messages (the same are read from journald)
修改为:$ModLoad imklog # reads kernel messages (the same are read from journald)

找到此行:$OmitLocalLogging on
修改为:#$OmitLocalLogging on

找到此行:$IMJournalStateFile imjournal.state
修改为:#$IMJournalStateFile imjournal.state

重启日志服务:systemctl restart rsyslog
tail -f /var/log/cron 发现有输入信息了