Hey guys, Got a quick question and I hope this is an easy one! In my /etc/logrotate.conf file I have the following entry: # rotate all of the apache logs -- we'll rotate them here /var/log/mysqld.log { weekly size 50M create 0644 mysql mysql rotate 1 } And from that I would expect the log to rotate when it reaches 50M in size. However I just caught that log weighing in at 356MB!! So how can I get this log file to rotate when it hits 50MB? Any ideas, advice and help at all would be appreciated. Thanks Tim -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
Have u tried removing the 'weekly' directive? You might consider replacing size with maxsize (details below) maxsize size Log files are rotated when they grow bigger than size bytes even before the additionally specified time interval (daily, weekly, monthly, or yearly). The related size option is similar except that it is mutually exclusive with the time interval options, and it causes log files to be rotated without regard for the last rotation time. When maxsize is used, both the size and timestamp of a log file are considered. -----Original Message----- From: centos-bounces at centos.org [mailto:centos-bounces at centos.org] On Behalf Of Tim Dunphy Sent: Thursday, January 08, 2015 3:55 AM To: CentOS mailing list Subject: [CentOS] logrotate script not working Hey guys, Got a quick question and I hope this is an easy one! In my /etc/logrotate.conf file I have the following entry: # rotate all of the apache logs -- we'll rotate them here /var/log/mysqld.log { weekly size 50M create 0644 mysql mysql rotate 1 } And from that I would expect the log to rotate when it reaches 50M in size. However I just caught that log weighing in at 356MB!! So how can I get this log file to rotate when it hits 50MB? Any ideas, advice and help at all would be appreciated. Thanks Tim -- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B _______________________________________________ CentOS mailing list CentOS at centos.org http://lists.centos.org/mailman/listinfo/centos
Check for selinux denials for logrotate. Chris On Jan 7, 2015 8:09 PM, "Mateusz Guz" <Mateusz.Guz at itworks.pl> wrote:> Have u tried removing the 'weekly' directive? > You might consider replacing size with maxsize (details below) > > maxsize size > Log files are rotated when they grow bigger than size bytes even before > the additionally specified time interval (daily, weekly, monthly, or > yearly). The related size option is similar except that it is mutually > exclusive with the time interval options, and it causes log files to be > rotated without regard for the last rotation time. When maxsize is used, > both the size and timestamp of a log file are considered. > > > -----Original Message----- > From: centos-bounces at centos.org [mailto:centos-bounces at centos.org] On > Behalf Of Tim Dunphy > Sent: Thursday, January 08, 2015 3:55 AM > To: CentOS mailing list > Subject: [CentOS] logrotate script not working > > Hey guys, > > Got a quick question and I hope this is an easy one! > > In my /etc/logrotate.conf file I have the following entry: > > # rotate all of the apache logs -- we'll rotate them here > /var/log/mysqld.log { > weekly > size 50M > create 0644 mysql mysql > rotate 1 > } > > And from that I would expect the log to rotate when it reaches 50M in size. > However I just caught that log weighing in at 356MB!! So how can I get > this log file to rotate when it hits 50MB? > > Any ideas, advice and help at all would be appreciated. > > Thanks > Tim > > -- > GPG me!! > > gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B > _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos > _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos >
Am 08.01.2015 um 03:54 schrieb Tim Dunphy:> Hey guys, > > Got a quick question and I hope this is an easy one! > > In my /etc/logrotate.conf file I have the following entry: > > # rotate all of the apache logs -- we'll rotate them here > /var/log/mysqld.log { > weekly > size 50M > create 0644 mysql mysql > rotate 1 > } > > And from that I would expect the log to rotate when it reaches 50M in size. > However I just caught that log weighing in at 356MB!! So how can I get > this log file to rotate when it hits 50MB?That's because the MySQL daemon has his hands on the log's file descriptor and still write the log while it has been moved by logrotate. You will have to add a command to the logrotate definition which causes the MySQL daemon to write into a new log file (mysqladmin flush-logs). https://dev.mysql.com/doc/refman/5.5/en/log-file-maintenance.html> Any ideas, advice and help at all would be appreciated. > > Thanks > TimAlexander
> > That's because the MySQL daemon has his hands on the log's file descriptor > and still write the log while it has been moved by logrotate. > You will have to add a command to the logrotate definition which causes > the MySQL daemon to write into a new log file (mysqladmin flush-logs). > https://dev.mysql.com/doc/refman/5.5/en/log-file-maintenance.htmlCool. Thanks!! I'll give that a try! Tim On Thu, Jan 8, 2015 at 2:02 AM, Alexander Dalloz <ad+lists at uni-x.org> wrote:> Am 08.01.2015 um 03:54 schrieb Tim Dunphy: > >> Hey guys, >> >> Got a quick question and I hope this is an easy one! >> >> In my /etc/logrotate.conf file I have the following entry: >> >> # rotate all of the apache logs -- we'll rotate them here >> /var/log/mysqld.log { >> weekly >> size 50M >> create 0644 mysql mysql >> rotate 1 >> } >> >> And from that I would expect the log to rotate when it reaches 50M in >> size. >> However I just caught that log weighing in at 356MB!! So how can I get >> this log file to rotate when it hits 50MB? >> > > That's because the MySQL daemon has his hands on the log's file descriptor > and still write the log while it has been moved by logrotate. > > You will have to add a command to the logrotate definition which causes > the MySQL daemon to write into a new log file (mysqladmin flush-logs). > > https://dev.mysql.com/doc/refman/5.5/en/log-file-maintenance.html > > Any ideas, advice and help at all would be appreciated. >> >> Thanks >> Tim >> > > Alexander > > > > > _______________________________________________ > CentOS mailing list > CentOS at centos.org > http://lists.centos.org/mailman/listinfo/centos >-- GPG me!! gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B
On Wed, Jan 7, 2015 at 9:54 PM, Tim Dunphy <bluethundr at gmail.com> wrote:> Hey guys, > > Got a quick question and I hope this is an easy one! > > In my /etc/logrotate.conf file I have the following entry: > > # rotate all of the apache logs -- we'll rotate them here > /var/log/mysqld.log { > weekly > size 50M > create 0644 mysql mysql > rotate 1 > } > > And from that I would expect the log to rotate when it reaches 50M in size. > However I just caught that log weighing in at 356MB!! So how can I get > this log file to rotate when it hits 50MB? >Given the other replies and your description... http://www.question-defense.com/2009/12/20/configure-logrotate-to-rotate-and-flush-mysql-logs-without-a-password (You already have this solution as your answer. But I find it interesting to read others' solutions and determine if mine could use improvement.) http://www.percona.com/blog/2014/11/12/log-rotate-and-the-deleted-mysql-log-file-mystery/ http://www.percona.com/blog/2013/04/18/rotating-mysql-slow-logs-safely/ http://forums.cpanel.net/f354/large-general-log-file-how-clean-up-safely-stop-reoccuring-278392.html http://ronaldbradford.com/blog/the-correct-approach-to-rolling-mysql-logs-2010-02-22/> > Any ideas, advice and help at all would be appreciated. >I'm a bit late on replying to this one ... in the past I've handled _binary_ log file (for replication) rotation via MySQL itself. * I realize the OP did not indicate he's using sql replication. But maybe this is helpful to somebody. In my case it was in regards to binary replication logs and specifically how many were retained (when MySQL began to purge). I also didn't blink at letting the logs grow to 1GB (the default for that version) but the size was configurable as well. max_binlog_size expire_logs_days http://dev.mysql.com/doc/refman/5.0/en/purge-binary-logs.html http://dev.mysql.com/doc/refman/5.0/en/log-file-maintenance.html -- ---~~.~~--- Mike // SilverTip257 //