Call us Toll-Free:
1-800-218-1525
Live ChatEmail us

 Sponsors

MySQL log rotate

Chris Tata, 03-06-2007
I've been getting weekly emails from our ISP about one of the MySQL database machines constantly running out of space.

Every other week I would go in and manually delete the mysqld.log log file. Got tired of doing this manually and worrying about it, so I wrote a simple script to automatically rotate MySQL log file.

I rotated the file (52gb) by hand and updated /etc/newsyslog.conf to include rotation of mysqld.log:

[root@spidb /var/log]# cat /etc/newsyslog.conf |grep sql
/var/log/mysqld.log mysql:wheel 660 4 * $D0 Z

Meaning "rotate mysqld.log every day at 00:00, save 4 days worth, change ownership to mysql:wheel with mode 660 and compress with gzip".

Had to also send a HUP signal to syslogd to reread the config file.
Enjoyed this post?

Subscribe Now to receive new posts via Email as soon as they come out.

 Comments
Post your comments












Note: No link spamming! If your message contains link/s, it will NOT be published on the site before manually approved by one of our moderators.



About Us  |  Contact us  |  Privacy Policy  |  Terms & Conditions