LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   logrotate && cron (https://www.linuxquestions.org/questions/linux-general-1/logrotate-and-and-cron-268467/)

pH* 12-20-2004 12:47 PM

logrotate && cron
 
Hi -- running YellowDog on my mac -- I think this is probably the best forum to ask in...

Having problems getting my logs to rotate. Specifically I'm worried about my httpd logs.

There is a script in /etc/cron.daily for logrotate, which looks fine:

Code:

#!/bin/sh

/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.d/httpd looks good to me:

Code:

/var/log/httpd/*log {
    rotate 5
    size=100k
    missingok
    notifempty
    sharedscripts
    postrotate
        /bin/kill -USR1 `cat /var/run/httpd.pid 2>/dev/null` 2> /dev/null || true
    endscript
}

the output from "logrotate -d /etc/logrotate.conf" looks good, except for the last line, which is:

error: bad year 1970 for file /var/log/cups/error_log in state file /var/lib/logrotate.status

and "/var/lib/logrotate.status" looks like this:
Code:

logrotate state -- version 2
"/var/log/cups/error_log" 1970-1-11
"/var/log/httpd/*log" 1970-1-11
"/var/log/named.log" 1970-1-11
"/var/log/ppp/connect-errors" 1970-1-11
"/var/account/pacct" 1970-1-11
"/var/log/rpmpkgs" 1970-1-11
"/var/log/samba/*.log" 1970-1-11
"/var/log/squid/access.log" 1970-1-11
"/var/log/squid/cache.log" 1970-1-11
"/var/log/squid/store.log" 1970-1-11
"/var/log/messages" 1970-1-11
"/var/log/secure" 1970-1-11
"/var/log/maillog" 1970-1-11
"/var/log/spooler" 1970-1-11
"/var/log/boot.log" 1970-1-11
"/var/log/cron" 1970-1-11
"/var/log/tux" 1970-1-11
"/var/log/yum.log" 1970-1-11
"/var/log/wtmp" 1970-1-11

When i set the computer up, I ran it for awhile before I thougt about syncing the clock to a network time server, so it thought it was the 70's all over again. Time is set up correctly now, but could this possibly be what is keeping my logs from rotating? And what exactly do I do to fix.. delete the contents of that last file?

XavierP 12-20-2004 01:15 PM

Moved: This thread is more suitable in Linux-General and has been moved accordingly to help your thread/question get the exposure it deserves.

Tinkster 12-20-2004 01:42 PM

I'd suggest "touching" all files to reflect a more recent
date ... :)


Cheers,
Tink

pH* 12-20-2004 01:59 PM

Well, the old dates are really only a part of the "/var/lib/logrotate.status" file... the actual files themselves in /etc/log/* all reflect current date/time-stamps (except for the files that don't get logged to because I don't use the service -- like cups).

So, pretty much all the files in the httpd directory (access_log, agent_log, etc), all have time-stamps of today.

I did notice something odd in "/etc/logrotate.d/":

Code:

total 48
-rwxr-xr-x  1 root root 161 Aug 14 13:24 cups*
-rw-r--r--  1 root root 202 Dec 17 09:36 httpd
-rw-r--r--  1 root root 345 Jun  1  2004 mysqld
-rw-r--r--  1 root root 163 May 25  2004 named
-rw-r--r--  1 root root 136 Aug 14 19:02 ppp
-rw-r--r--  1 root root 242 May 25  2004 psacct
-rw-r--r--  1 root root  61 May 18  2004 rpm
-rw-r--r--  1 root root 232 May 26  2004 samba
-rw-r--r--  1 root root 543 Aug 16 15:04 squid
-rw-r--r--  1 root root 228 May 19  2004 syslog
-rw-r--r--  1 root root  48 Jun  7  2004 tux
-rw-r--r--  1 root root  89 Jun  3  2004 yum

The cups script is a+x, while none of the others are. Now, I'm not using cups, so the log isn't getting written to, so if these files need to be set executable for logrotate to run them, I'd never know based off just cups being set that way.

I've set the httpd script a+x to match cups, and I guess we'll see if that solves the problem, but I don't understand why this installation set up logrotate.d like this... seems odd for a default server install.

If you recognize that this is probabaly the cause of my problem, I certainly wouldn't mind you posting back to let me know... otherwise, I guess we'll wait until tonite to see. :)

Tinkster 12-20-2004 02:24 PM

That executable bit shouldn't make a difference ...

What I'd suggest is to see what happens if you
manually update the state file now ... :) (after having
made a backup-copy, of course ;}) ...

sed -i 's/1970-1-11/2004-10-11/g' var/lib/logrotate.status


Cheers,
Tink

pH* 12-20-2004 02:46 PM

OK, we'll give that a shot and see what happens.

As an aside -- there's no specific reason you picked 2004-10-11 is there? It doesn't appear anywhere else really... your birthday, maybe? :) (Or you really like Eleanor Roosevelt.)

Tinkster 12-20-2004 02:48 PM

I actually picked it because that is what my status file has ;)



Cheers,
Tink

pH* 12-20-2004 02:53 PM

In that case, I hope yours is working. ;-D

Tinkster 12-20-2004 02:55 PM

Heh ... it is ;)


Cheers,
Tink

pH* 12-21-2004 10:38 AM

All logs seem to be getting rotated correctly now.

The solution was Tink's updating of the logrotate state file with:

sed -i 's/1970-1-11/2004-10-11/g' var/lib/logrotate.status

Seemed to do the trick.

My suggestion that setting the executable bit on the httpd script in /etc/logrotate.d couldn't have been the solution because as of now, there are only two scripts in that file with executable bits set - the httpd and cups scripts - and many more logs than those associated with those two scripts have been rotated by cron overnite.

Many thx to Tink -- expect an affero soon!


All times are GMT -5. The time now is 11:48 AM.