Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a log file a service of mine makes that has the filename "Feed1 - 1.stat". logrotate refuses to rotate this file, but only when run via cron. Running logrotate via the shell will rotate the file correctly. Changing the config and and log file to not have a space will also result in the file rotating correctly.

Heres the relevant part of the script script:

"/opt/myservice/statistics/continuous/Feed1 - 1.stat"
{
  rotate 60
  daily
  missingok
  notifempty
  compress
  delaycompress
  postrotate
    /usr/bin/killall -HUP myservice
  endscript
}

And here's the cron entry that kicks off logrotate (Ubuntu default):

#!/bin/sh

# Clean non existent log file entries from status file
cd /var/lib/logrotate
head -1 status > status.clean
sed 's/"//g' status | while read logfile date
do
    [ -e "$logfile" ] && echo "\"$logfile\" $date"
done >> status.clean
mv status.clean status

test -x /usr/sbin/logrotate || exit 0
/usr/sbin/logrotate /etc/logrotate.conf

I suspect something perhaps related to enviroment variables? I can see the cron enviroment is rather sparse, but don't know how to debug this from here on.

Any ideas? Thanks :-)


Ubuntu 11.04 Natty 64 bit

2.6.38-8-server

logrotate 3.7.8-6ubuntu3.1


Edits:

  • Rewrote question as I found out it doesn't have to do with the wildcard matching
share|improve this question
    
Use "apt-cache policy logrotate" to see the version information (installed and available). –  lsmooth Feb 13 '12 at 15:46
    
Atat is set to monthly? Are you sur that is what you want? That means rotatae once a month. –  Zoredache Feb 13 '12 at 15:49
    
Thanks - updated –  Frederik Feb 13 '12 at 15:49
    
Zoredache, not sure what you mean by "Atat", but the two "monthly"'s are deliberate - they are small logs which I don't want changing all the time. The one I'm having trouble with is meant to change daily, though –  Frederik Feb 13 '12 at 15:51
    
Could we see your cron entry? –  Aaron Copley Feb 13 '12 at 15:57

2 Answers 2

up vote 1 down vote accepted

The Ubuntu logrotate cron script is broken and strips out the double quotation marks from the status file. It then checks if the file exists, which it doesn't because the quotes are gone, and removes the line. Then logrotate re-adds the line on execution, but as it just added it, doesn't rotate. Ad infinitum.

I'll file a bug on Launchpad.

Edit: And heres the bug report: https://bugs.launchpad.net/ubuntu/+source/logrotate/+bug/932225

share|improve this answer

It sounds like problem with permissions. did you check that ? {I suppose that in console you execute lograte as root }

Except for that, just to mention that you can always rotate it by size, not only by time.

share|improve this answer
    
Thanks Nikolaidis - good idea - looking into it now –  Frederik Feb 13 '12 at 16:15
    
Nikolaidis, I just looked it up: cron runs as root, and kicks of logrotate running as root too, so I don't think it's that –  Frederik Feb 13 '12 at 16:31
    
Hmmmm. do you have cron's logs ? they may give a hint –  Nikolaidis Fotis Feb 13 '12 at 17:11
    
Just noticed ... third and fourth are under /opt, while first and second under /var/log .... So ... could you recheck permissions in /opt ? {As root, try to append something in "/opt/myservice/statistics/continuous/*.stat" } –  Nikolaidis Fotis Feb 13 '12 at 17:13
    
Nikolaidis, I can happily edit those files as root. I can't see much in /var/log about cron - a couple messages in syslog, but thats it. I've setup the logrotate cron script to run in verbose mode and log its output, so maybe we'll see tomorrow. Thanks! –  Frederik Feb 13 '12 at 18:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.