LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Need help in using linux utility logrotate (https://www.linuxquestions.org/questions/linux-newbie-8/need-help-in-using-linux-utility-logrotate-933883/)

Tarun.Soni 03-11-2012 08:55 AM

Need help in using linux utility logrotate
 
Hi All,

I have to make a utility that can monitor a log file and if it reaches some size (say 1k), it should create another file in rotation and compress and zip it. I want to use existing utility of Linux like logroate. But logrotate is not working properly here. Can any body tell me the reason.

Folllowings are logroate configuration

linux system kernel 2.6.27.39

I am modifying /etc/logrotate.conf like this

/rmem/slave //file name
{
missing ok
compress
copytruncate
size 1k
rotate 4
}

According to above configuration, logrotate should monitor the file /rmem/slave, once the file reaches its size 1 kilo byte, it should create new file and conpress and zipped it like slave.1.gz.
in ths same way it should create slave.2.gz, on reaching another 1 kilo byte in the same way slave.3.gz should also be created once size reaches another 1k,and similarly slave.4.gz

My Question is here this size command is not working properly in logrotate.conf

i have mentioned here 1k, but it is not creating zip file after /rmem/slave reaches 1k,but when it reaches 100k -200k, then it is creating the new file. and also it is creating the zip file of 10k sometime 9k, sometime 11 k

I am not understanding the behavior of size in logrotate.conf


Can any body help me?

catkin 03-11-2012 09:01 AM

logrotate is normally run daily

poettone 04-09-2012 04:10 PM

Small Sizes
 
When you are talking about 1 kilobyte you are referring to a very small amount of data. My guess is log rotate is getting confused and not able to function as your file size designated is way to small thus it might be trying to force itself into to many actions too fast. Hence the 100-200k.. My belief at this point is logrotate has a limit on the minumum size of file it can work with but I'm only speculating on this. Now if you said 1 MB or 100Kilobyte, this might allow it to work properly.

I would do a search and look for something along the lines of "what is the minumum file size logrotate can operate on".. This may or may not provide some clues.


Best of luck on that one.


All times are GMT -5. The time now is 06:31 AM.