Meaning of logrotate parameters.

Solution Unverified - Updated -

Environment

  • Red Hat Enterprise Linux 4 (Nahant Update 4).
  • Red Hat Enterprise Linux 5
  • Red Hat Enterprise Linux 6

Issue

  • Meaning of following logrotate parameters :
    ifempty
    missingok
    noolddir
    daily
    compress
    copytruncate
    rotate 40

  • Will the parameters function as follows :

    Understanding 1 - This function will copy the current *.log file to *.log1 and compress it to *.log1.gz then will make the current running *.log file as Zero byte by nullifying it.

    OR

    Understanding 2 - This function will move the current *.log file to *.log1 and compress it to *.log1.gz then createa new *.log file which is zero byte

Resolution

  • Meaning of following logrotate parameters as per man logrotate.conf :

    ifempty : Rotate the log file even if it is empty, overriding the notifempty option (ifempty is the default).

    missingok : If the log file is missing, go on to the next one without issuing an error message.

    noolddir : Logs are rotated in the same directory the log normally resides in (this overrides the olddir option).

    daily : Log files are rotated every day.

    compress : Old versions of log files are compressed with gzip(1) by default.

    copytruncate : Truncate the original log file 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.

    rotate 40 : Log files are rotated count times before being removed or mailed to the address specified in a mail directive. If count is 0, old versions are removed rather than rotated. Here , count is 40.

  • Will the parameters function as follows :

    Understanding 1 - This function will copy the current *.log file to *.log1 and compress it to *.log1.gz then will make the current running *.log file as Zero byte by nullifying it.

    OR

    Understanding 2 - This function will move the current *.log file to *.log1 and compress it to *.log1.gz then create a new *.log file which is zero byte

    Since , copytruncate is being used the first (Understanding 1 ) is correct. As copytruncate truncates the original log file in place after creating a copy , instead of moving old log file and optionally creating a new one.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments