Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

thegeekstuff has an example about logrotate. copytruncate will copy and truncate the original log file. Then why we should use create? The original log file has not been removed.

/tmp/output.log {
        size 1k
        copytruncate
        create
        compress
        compresscmd /bin/bzip2
        compressext .bz2
        rotate 4
        maxage 100
}

Another question is what is the use of maxage 100? The rotate 4 directive will delete old log files after 4 rotation.

share|improve this question
3  
Yes, that doesn't make sense and man logrotate even says so: "copytruncate: [...] When this option is used, the create option will have no effect, as the old log file stays in place." –  Ulrich Schwarz Mar 5 '12 at 8:16
add comment

1 Answer

up vote 6 down vote accepted

That is probably a mistake, it is found only in one example on that tutorial. All other examples have copytruncate without the create option. Also logrotate man page says that is will be actually ignored:

copytruncate

Truncate the original log file to zero size in place after creating a copy, instead of moving the old log file and optionally creating a new one. It can be used when some program cannot be told to close its logfile and thus might continue writing (appending) to the previous log file forever. Note that there is a very small time slice between copying the file and truncating it, so some logging data might be lost. When this option is used, the create option will have no effect, as the old log file stays in place.

Regarding maxage, I think it can be useful for example for logfiles which can be empty for few roration periods (days/weeks/months) - if you use notifempty, empty logfile will not be rotated, so you can have too old rotated files still in place.

share|improve this answer
add comment

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.