Some questions about Logrotate.conf

Hi all,

I have to configure the logrotate.conf file on some Linux RedHat servers.
So, by default I seen the file is as follow:

# see "man logrotate" for details
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# uncomment this if you want your log files compressed
#compress

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp -- we'll rotate them here
/var/log/wtmp {
    monthly
    minsize 1M
    create 0664 root utmp
    rotate 1
}

# system-specific logs may be also be configured here.

At this point I have a couple of questions for you:

1) As configurated, this file manages logs system files, correct?

2) Now, I have to manage log files (called monitoring.log) produced by a custom script created by myself (monitoring.sh).

I'd want this log be emptied everyday, at a certain hour, and old log files be archived everyday.

The script and log path is /root.

How do I have to configure my logrotate?

Thanks for your answers
bye

No, only wtmp will be rotated by default. Take a look in /etc/logrotate.d what else might get rotated.

What does the very first line in your logrotate.conf say? Did you read it? Did you understand it? If not, post concrete questions, but don't ask us to do your work.

Ok, you're right and I'm sorry for this.

I read documentation e I've just done my script to handle my monitoring log files, that it's simply as follow:

#handle monitoring log

/root/monitoring {

     daily
     rotate 5
     notifempty
     nocreate

     endscript
}

This times I hope not to make a wrong question, but I didn't really understand how to synchronize my monitoring.sh custom script (see post below) and the actions of logrotate on monitoring.log.
Maybe logrotate starts at the end of monitoring.sh, or not?

THX

First, drop the endscript directive. It's only valid if you've got a prerotate or postrotate somewhere in there.

Second, it depends on how logging is implemented in your script to say how to best inform it of a rotation. If you're just logging with lines like

echo "Log message" >> $log

or similar, you don't have to do anything. If your script only runs at intervals and probably won't cross times with logrotate, you don't have to do anything.

If, however, your script runs most of the time, and opens a file descriptor for the log at the beginning, you'll probably have to close and re-open that fd. The easiest way would be a trap on SIGHUP, and an appropriate postrotate script.

I'm logging with the line hereafter:

if [[ "$1" == "stop" ]]
        then
                stop
        else
                nohup vmstat $1 |eg >> monitoring.log &
        fi

Further, I added the directive "missingok" in case the file is missing, correct?.

Edit by pludi: please, use the code tags for code and listings

Isn't vmstat usually a 1-shot command? So what's the nohup for? And what's the eg command?