LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 09-25-2008, 06:35 AM   #1
bujecas
Member
 
Registered: Oct 2004
Location: Portugal
Distribution: Debian, Slackware
Posts: 78

Rep: Reputation: 20
Logrotate copytruncate alternative


Hello,

I have a Syslog-NG server write to some log files and a program (SEC) reading from them. The SEC needs to have the same file opened, so I was using the copytruncate in the logrotate of the log files. My problem is that I'm losing some log entries during the rotation.

Here's my logrotate configuration file:

Code:
/srv/syslog/pulso/*.log {
        rotate 2
        copytruncate
        compress
        ifempty
        missingok
        lastaction
                find /srv/syslog/pulso/*.log.{1,2}.gz 2>/dev/null |while read f; do
                        DATA=`date +%Y-%m-%d`
                        HORA=`date +%H`
                        HORA=`expr $HORA - 1`
                        [ "$HORA" == "-1" ] && HORA=23
                        HORA=`printf "%02d" $HORA`

                        new_filename=`echo $f |sed 's/\.[12]\.gz//'`
                        mv $f $new_filename.${DATA}_${HORA}.gz
                done
        endscript
}
There's any alternative to copytruncate without losing events? The lastaction that I have, could slow down the process?

Thanks.
 
Old 09-28-2008, 04:14 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by bujecas View Post
There's any alternative to copytruncate without losing events?
I don't know if it's possible for you but SEC can read from named pipes. You could 'mkfifo' one and let SEC read from there during this logrotate?


Quote:
Originally Posted by bujecas View Post
The lastaction that I have, could slow down the process?
Slow down yes, effect on "copytruncate" no (I would think). You could avoid worrying about it by for example moving the postrotate script to a script file and let 'at' handle it ('at -f /some/script now'). Handing it off that way frees logrotate to move on to the next logrotate action.
 
  


Reply



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
logrotate invent Linux - Enterprise 1 08-19-2008 08:45 AM
logrotate Ronin_tekorei Linux - Newbie 2 02-07-2008 05:44 AM
About logrotate satimis *BSD 1 05-27-2007 01:08 PM
logrotate Rig24 Linux - Newbie 2 07-11-2003 05:08 AM
logrotate MrJoshua Linux - General 2 09-25-2002 09:55 AM

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

All times are GMT -5. The time now is 05:07 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