LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 12-20-2004, 12:47 PM   #1
pH*
Member
 
Registered: Nov 2003
Distribution: Slackware 10
Posts: 40

Rep: Reputation: 15
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?
 
Old 12-20-2004, 01:15 PM   #2
XavierP
Moderator
 
Registered: Nov 2002
Location: Kent, England
Distribution: Debian Testing
Posts: 19,192
Blog Entries: 4

Rep: Reputation: 475Reputation: 475Reputation: 475Reputation: 475Reputation: 475
Moved: This thread is more suitable in Linux-General and has been moved accordingly to help your thread/question get the exposure it deserves.
 
Old 12-20-2004, 01:42 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

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


Cheers,
Tink
 
Old 12-20-2004, 01:59 PM   #4
pH*
Member
 
Registered: Nov 2003
Distribution: Slackware 10
Posts: 40

Original Poster
Rep: Reputation: 15
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.
 
Old 12-20-2004, 02:24 PM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
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
 
Old 12-20-2004, 02:46 PM   #6
pH*
Member
 
Registered: Nov 2003
Distribution: Slackware 10
Posts: 40

Original Poster
Rep: Reputation: 15
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.)
 
Old 12-20-2004, 02:48 PM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
I actually picked it because that is what my status file has ;)



Cheers,
Tink
 
Old 12-20-2004, 02:53 PM   #8
pH*
Member
 
Registered: Nov 2003
Distribution: Slackware 10
Posts: 40

Original Poster
Rep: Reputation: 15
In that case, I hope yours is working. ;-D
 
Old 12-20-2004, 02:55 PM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Heh ... it is ;)


Cheers,
Tink
 
Old 12-21-2004, 10:38 AM   #10
pH*
Member
 
Registered: Nov 2003
Distribution: Slackware 10
Posts: 40

Original Poster
Rep: Reputation: 15
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!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
zsnes && logitech dual action gamepad && dpad woes John5788 Linux - Games 5 10-29-2008 09:56 PM
(FreeBSD && Fedora Core 4 && Slackware 10.0) Filesystem Support taylor_venable *BSD 1 07-14-2005 02:24 PM
cron.daily & logrotate cccc SUSE / openSUSE 1 07-08-2005 12:06 PM
Japanese canna won't work : Warning: かな漢字変&am OrganicOrange84 Debian 3 06-30-2005 02:28 PM
Phục hồi dữ liệu bị mất???, cứ pollsite General 1 06-27-2005 12:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration