Getting Daily /etc/cron.daily/logrotate error mail. Help needed.

sahithp

Member
Jun 13, 2011
15
1
53
I am getting the following mail daily. Please help me out

From : Cron Daemon [email protected]
Subject : Cron <[email protected]> run-parts /etc/cron.daily

Subject :

/etc/cron.daily/logrotate:

error: /etc/logrotate.conf:3 unexpected text
error: /etc/logrotate.conf:4 lines must begin with a keyword or a filename (possibly in double quotes)
error: /etc/logrotate.conf:6 unexpected text
error: /etc/logrotate.conf:7 lines must begin with a keyword or a filename (possibly in double quotes)
error: /etc/logrotate.conf:9 unexpected text
error: /etc/logrotate.conf:10 lines must begin with a keyword or a filename (possibly in double quotes)
error: /etc/logrotate.conf:12 unexpected text
error: /etc/logrotate.conf:13 lines must begin with a keyword or a filename (possibly in double quotes)
error: /etc/logrotate.conf:15 lines must begin with a keyword or a filename (possibly in double quotes)
error: /etc/logrotate.conf:16 unexpected text
error: /etc/logrotate.conf:17 unexpected text
error: /etc/logrotate.conf:18 unexpected text
error: /etc/logrotate.conf:19 unexpected text
error: /etc/logrotate.conf:20, unexpected text after {
error: /etc/logrotate.conf:20 lines must begin with a keyword or a filename (possibly in double quotes)
error: /etc/logrotate.conf:21 lines must begin with a keyword or a filename (possibly in double quotes)
error: /etc/logrotate.conf:23 lines must begin with a keyword or a filename (possibly in double quotes)

/etc/cron.daily/logrotate File :
Code:
#!/bin/sh
export TMPDIR=/var/spool/logrotate/tmp

/usr/sbin/logrotate /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
    /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit 0
etc/logrotate.conf File :
Code:
# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 1

# create new (empty) log files after rotating old ones
create

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp -- we'll rotate them here
/var/log/wtmp {
    monthly
    minsize 1M
    create 0664 root utmp
    rotate 1
}

# system-specific logs may be also be configured here.
HOPE SOMEBODY HELPs :)
 
Last edited:

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
Try this on /etc/logrotate.conf file:

Code:
file /etc/logrotate.conf
It should show the following:

Code:
# file /etc/logrotate.conf 
/etc/logrotate.conf: ASCII text
If instead it shows this:

Code:
/etc/logrotate.conf: ASCII text, with CRLF line terminators
Then you need to get rid of the DOS-style line ends in the file:

Code:
cp /etc/logrotate.conf /etc/logrotate.conf.bak110614
dos2unix -b /etc/logrotate.conf
If you get that dos2unix isn't installed, then first install it using yum:

Code:
yum install dos2unix
At that point, then re-do the commands mentioned previously.
 

sahithp

Member
Jun 13, 2011
15
1
53
Now i am getting the following error mail after adding

# file /etc/logrotate.conf
/etc/logrotate.conf: ASCII text

Code:
error: /etc/logrotate.conf:2 lines must begin with a keyword or a filename (possibly in double quotes)
error: /etc/logrotate.conf:3 unexpected text
error: /etc/logrotate.conf:4 unexpected text
error: /etc/logrotate.conf:5 unexpected text
error: /etc/logrotate.conf:6 unexpected text
error: /etc/logrotate.conf:7, unexpected text after {
error: /etc/logrotate.conf:7 lines must begin with a keyword or a filename (possibly in double quotes)
error: /etc/logrotate.conf:8 lines must begin with a keyword or a filename (possibly in double quotes)
error: /etc/logrotate.conf:10 lines must begin with a keyword or a filename (possibly in double quotes)
error: stat of /etc/logrotate.conf: failed: No such file or directory
error: stat of ASCII failed: No such file or directory
error: stat of text failed: No such file or directory
error: stat of # failed: No such file or directory
error: stat of see failed: No such file or directory
error: stat of man logrotate failed: No such file or directory
error: stat of for failed: No such file or directory
error: stat of details failed: No such file or directory
error: stat of # failed: No such file or directory
error: stat of rotate failed: No such file or directory
error: stat of log failed: No such file or directory
error: stat of files failed: No such file or directory
error: stat of weekly failed: No such file or directory
error: stat of weekly failed: No such file or directory
error: stat of # failed: No such file or directory
error: stat of keep failed: No such file or directory
error: stat of 4 failed: No such file or directory
error: stat of weeks failed: No such file or directory
error: stat of worth failed: No such file or directory
error: stat of of failed: No such file or directory
error: stat of backlogs failed: No such file or directory
error: stat of rotate failed: No such file or directory
error: stat of 1 failed: No such file or directory
error: stat of # failed: No such file or directory
error: stat of create failed: No such file or directory
error: stat of new failed: No such file or directory
error: stat of (empty) failed: No such file or directory
error: stat of log failed: No such file or directory
error: stat of files failed: No such file or directory
error: stat of after failed: No such file or directory
error: stat of rotating failed: No such file or directory
error: stat of old failed: No such file or directory
error: stat of ones failed: No such file or directory
error: stat of create failed: No such file or directory
error: stat of # failed: No such file or directory
error: stat of RPM failed: No such file or directory
error: stat of packages failed: No such file or directory
error: stat of drop failed: No such file or directory
error: stat of log failed: No such file or directory
error: stat of rotation failed: No such file or directory
error: stat of information failed: No such file or directory
error: stat of into failed: No such file or directory
error: stat of this failed: No such file or directory
error: stat of directory failed: No such file or directory
error: stat of include failed: No such file or directory
error: stat of # failed: No such file or directory
error: stat of no failed: No such file or directory
error: stat of packages failed: No such file or directory
error: stat of own failed: No such file or directory
error: stat of wtmp failed: No such file or directory
error: stat of -- failed: No such file or directory
error: stat of well rotate them here
/var/log/wtmp  failed: No such file or directory
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
You didn't add or change anything by running the command to check the file type. The file type already appears to be correct, since it is only showing ASCII text and not anything else like my examples if it did have other characters in the file.

Can you please run the following commands and provide the output:

Code:
ls -lah /etc/logrotate.conf
lsattr /etc/logrotate.conf
We should see the following for the correct permissions:

Code:
[email protected] [~]# ls -lah /etc/logrotate.conf
-rw-r--r-- 1 root root 520 Nov  5  2010 /etc/logrotate.conf

[email protected] [~]# lsattr /etc/logrotate.conf
------------- /etc/logrotate.conf
The reason I'm wondering what is going on with the file is that it has this error message:

Code:
error: stat of /etc/logrotate.conf: failed: No such file or directory