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
    /usr/bin/killall -HUP myservice

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


# 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
    [ -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


logrotate 3.7.8-6ubuntu3.1


  • Rewrote question as I found out it doesn't have to do with the wildcard matching
  • 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
  • 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
  • Aaron, crontab added – Frederik Feb 13 '12 at 16:02

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

| 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.

| improve this answer | |
  • 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

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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