Message 1:
From [email protected] Wed May 2 03:01:02 2012
Date: Wed, 2 May 2012 03:01:02 +0400
From: [email protected] (Cron Daemon)
To: [email protected]
Subject: Cron <root@server> test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
Content-Type: text/plain; charset=ANSI_X3.4-1968
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <LOGNAME=root>
/etc/cron.daily/logrotate:
head: cannot open `status' for reading: No such file or directory
sed: can't read status: No such file or directory
我该如何修复它?
答案1
我认为如果你看一下 /etc/cron.daily/logrotate - 你会发现脚本正在检查是否存在(以及写入能力):/var/lib/logrotate/status
在我的 /etc/cron.daily/logrotate 脚本中,head 命令前面有一行,它将首先测试是否存在“status”文件,或者使用 touch 创建该文件:test -e status || touch status head -1 status > status.clean
可能是您无法使用 touch 命令将“status”文件写入“/var/lib/logrotate/”?我会进入 /var/lib/logrotate//logrotate,看看是否可以使用以下命令手动创建“status”文件(假设该文件尚不存在): touch status 。也许该目录没有剩余磁盘空间?使用 df -h /var/lib/logrotate/ 检查,或者可能将其设置为不可变(不知道为什么会这样)。
答案2
您可以参考以下博客链接进行详细讨论:http://teklimbu.wordpress.com/2007/10/16/managing-your-linuxunix-log-files-using-logrotate/
一个快速而肮脏的技巧是在你的服务器上touch
创建一个空文件。/var/lib/logrotate/status
简单介绍一下背景:
logrotate
是一个实用程序,可以旋转日志文件并将其存档到指定位置。
cron
是一种可用于安排运行/自动执行特定任务的服务。
现在,显然,因为计划任务在服务器上计划运行日志旋转每天编写脚本,而脚本又期望地位文件存在(但不存在),您的服务器就会抛出这些错误消息。
希望能帮助到你。