Solved need help with log rotation

Hi Guys,

I have a small webserver running inside a FreeBSD 10.2 jail with www/hiawatha.
We just notice that the webserver is generating huge daily log files and taking much of the jail space allocation...

In order to tackle the issue I have been looking at syslog and sysutils/logrotate to rotate and delete the log but I cannot workout what is the difference between the two..

Could someone please advise on which one to use in my schenario?
 
Just use the standard newsyslog(8) (despite its name it can handle other logs besides syslog too). No need to install anything.

This is what I use for Apache, /usr/local/etc/newsyslog.conf.d/apache.conf:
Code:
# Apache
/var/log/httpd-access.log               644  14     *    @T00  JB     /var/run/httpd.pid 30
/var/log/httpd-error.log                644  14     *    @T00  JB     /var/run/httpd.pid 30
 
No, you can't use wildcards.

The last two columns of the file indicate it should send a signal to the PID in /var/run/httpd.pid. In this case it sends a SIGUSR1 (30) to the Apache process, this forces Apache to close the file descriptors for logging and start a new file.
 
SirDice
Sorry to come back to you but I have another question..
Code:
/var/log/httpd-error.log                644  14     *    @T00  JB     /var/run/httpd.pid 30
I understand that the above code will rotate the file httpd-error.log and will regenerate a new one with permission 644 and keep 14 copies of the file
You already explain what the last two columns do..
Could you please confirm that @T00 JB is use to rotate every night at midnight?

Also, how do I make sure the owner of the file is www-www
 
The JB are flags that have nothing to do with the time:
Code:
             B       indicates that the log file is a binary file, or has some
                     special format.  Usually newsyslog(8) inserts an ASCII
                     message into a log file during rotation.  This message is
                     used to indicate when, and sometimes why the log file was
                     rotated.  If B is specified, then that informational mes-
                     sage will not be inserted into the log file.
Code:
             J       indicates that newsyslog(8) should attempt to save disk
                     space by compressing the rotated log file using bzip2(1).

The @T00 does indeed indicate midnight.

Code:
             ISO 8601 restricted time format:

             The lead-in character for a restricted ISO 8601 time is an `@'
             sign.  The particular format of the time in restricted ISO 8601
             is: [[[[[cc]yy]mm]dd][T[hh[mm[ss]]]]].  Optional date fields
             default to the appropriate component of the current date;
             optional time fields default to midnight; hence if today is Jan-
             uary 22, 1999, the following date specifications are all equiva-
             lent:

                   `19990122T000000'
                   `990122T000000'
                   `0122T000000'
                   `22T000000'
                   `T000000'
                   `T0000'
                   `T00'
                   `22T'
                   `T'
                   `'

See newsyslog.conf(5).
 
No, you can't use wildcards
I'm able to use wildcards. You just need to use the "G" flag :
Code:
             G       indicates that the specified logfile_name is a shell pat-
                     tern, and that newsyslog(8) should archive all filenames
                     matching that pattern using the other options on this
                     line.  See glob(3) for details on syntax and matching
                     rules.
Code:
/var/log/nginx/*.log    nginx:wheel        640  4     *    $W1D0  GJB  /var/run/nginx.pid 30
 
Back
Top