logrotate prerotate not working???

logrotate prerotate not working???

Post by B Walke » Fri, 28 Mar 2003 21:48:22



I have a shell script that updates my apache access stats (awstats).  If
I call it from a prompt, the script works fine...  But, when I put it in
a prerotate section of my apache logrotate config file.. it doesn't seem
to get run.  I've setup my logrotate cron job to output debugging info,
and it says it's running the prerotate..but nada (I know this because
the script outputs it's last run information to a text file).

So, here's the apache file from /etc/logrotate.d I'm running RH7.3 (with
all the latest updates).  I've just changed the prerotate line to
"/bin/sh /opt/apache/bin/updatestats" but I'll have to wait until early
tomorrow morning to find out if that works.  Thought I'd ask here ;-)

Oh, and permissions are fine.... the script is running as root anywho.

tia.

/opt/apache/logs/*_log {
     notifempty
     missingok
     sharedscripts
     copytruncate
     daily
     rotate 10
   prerotate
         /opt/apache/bin/updatestats
   endscript
   postrotate
         /sbin/service httpd restart > /dev/null 2> /dev/null
   endscript

Quote:}

--
DoD# 2223, OFCC #3122
Meum scapha volitare plenum anguillae
 
 
 

logrotate prerotate not working???

Post by dav.. » Fri, 28 Mar 2003 21:58:27



> I call it from a prompt, the script works fine...  But, when I put it in
> a prerotate section of my apache logrotate config file.. it doesn't seem
> to get run.

Problem with the PATH?

Quote:> /opt/apache/bin/updatestats

What's in updatestats ? Is it a binary or a shell script

Davide

 
 
 

logrotate prerotate not working???

Post by B Walke » Fri, 28 Mar 2003 22:12:30




>>I call it from a prompt, the script works fine...  But, when I put it in
>>a prerotate section of my apache logrotate config file.. it doesn't seem
>>to get run.

> Problem with the PATH?

>>/opt/apache/bin/updatestats

> What's in updatestats ? Is it a binary or a shell script

> Davide

It's a shell script, and yup it's got +x ;-).  I can go to a command
prompt and type /opt/apache/bin/updatestats and it works just fine.

Updatestats (work wrapping mucked it a bit, but here it is):

#!/bin/bash
/opt/apache/cgi-bin/awstats.pl -config=gta -update >
/opt/apache/logs/lastupdate_gta
/opt/apache/cgi-bin/awstats.pl -config=Walkervision -update >
/opt/apache/logs/lastupdate_wv

(btw: /bin/sh is linking to /bin/bash, if it matters ;-)
--
DoD# 2223, OFCC #3122
Meum scapha volitare plenum anguillae

 
 
 

logrotate prerotate not working???

Post by dav.. » Fri, 28 Mar 2003 22:36:55



> It's a shell script, and yup it's got +x ;-).  I can go to a command
> prompt and type /opt/apache/bin/updatestats and it works just fine.

Maybe it works because you have something in your PATH but that
something is not in the path of the cron job that execute the
logrotate scripts.

Davide

 
 
 

logrotate prerotate not working???

Post by B Walke » Sat, 29 Mar 2003 03:28:38




>>It's a shell script, and yup it's got +x ;-).  I can go to a command
>>prompt and type /opt/apache/bin/updatestats and it works just fine.

> Maybe it works because you have something in your PATH but that
> something is not in the path of the cron job that execute the
> logrotate scripts.

> Davide

Well, now that I've put in /bin/sh /opt/apache/bin/updatestats..
everything (and I do mean everything) has a full path.. perhaps it'll
work then..

I presume there was nothing wrong with my setup in the logrotate script?

--
DoD# 2223, OFCC #3122
Meum scapha volitare plenum anguillae

 
 
 

logrotate prerotate not working???

Post by dav.. » Sat, 29 Mar 2003 03:51:48



> I presume there was nothing wrong with my setup in the logrotate script?

Not that I can see.
Davide
 
 
 

logrotate prerotate not working???

Post by B Walke » Sun, 30 Mar 2003 00:06:24




>>I presume there was nothing wrong with my setup in the logrotate script?

> Not that I can see.
> Davide

Still not working at all..odd.  Well, I worked around it by changing my
logrotate script (in cron.daily) to 99-logrotate and creating a
98-updatestats script... and removing the postrotate ;-).. That'll fix
it (although non-optimal, it'll work).

--
DoD# 2223, OFCC #3122
Meum scapha volitare plenum anguillae

 
 
 

1. logrotate Not Executing Prerotate Script

I found a previous post where someone wanted to their logs with the date
appended to the end.  It was suggested to use the following code in the
"prerotate" section:

/var/log/httpd/access_log {
    daily
    rotate 0
    prerotate
     /bin/cp -f /var/log/httpd/access_log
/var/log/httpd/access_log.`/bin/date +&Y%b%d`
    endscript

I added this script to /etc/logrotate.d/apache .  But when it runs, it
doesn't rename the log file.

My /etc/logrotate.conf file looks like:

# rotate log files weekly
weekly
# keep 4 weeks worth of backlogs
rotate 4
# send errors to root
errors root
# create new (empty) log files after rotating old ones
create
# uncomment this if you want your log files compressed
compress
# RPM packages drop log rotation information into this directory
include /etc/logrotate.d
# no packages own lastlog or wtmp -- we'll rotate them here
/var/log/wtmp {
    monthly
    create 0664 root utmp
    rotate 1

/var/log/lastlog {
    monthly
    rotate 1

# system-specific logs may be configured here

I assumed that having the apache file it would "over-ride" the general
preferences, but it doesn't appear to be the case.

Any help would be greatly appreciated.

-Ken Schweigert

Sent via Deja.com http://www.deja.com/
Before you buy.

2. Programs from STB to make Xfree work - stbvl24_.z (1/1)

3. Logrotate...or not?

4. C++ Compiler/libraries

5. Squid does not receive logrotate signal when start with remote software

6. TCP/IP configs

7. Kernel-nfs working, plain nfs not working.

8. Is PROCMAIL/SENDMAIL/SMTP/UUCP Possible?

9. USB not working with 2.5.69, worked with .68

10. PPP working, /etc/ppp/ip-up not working, HELP Please

11. smtp mmdf not working for SCO 5.0 (send ok but not receive)

12. Kernel Compile - cdrom will not work, modules are not presents

13. PPPD w/ PAP not working, works fine w/o PAP