Mysql – How should I rotate rsyslog documents stored in thesql

logrotateMySQLrsyslog

I have setup rsyslog to dump syslog data into mysql so that LogAnalyzer can easily access and interact with it.

How do I automate a job to remove syslog data of a certain age for the mysql database so it doesn't fill my HD?

Best Answer

Have a cronjob executing a query like the following once a day:

 delete from syslogtable where timestampfield < subdate(curdate(), 31); 

Here, syslogtable is the table in question, timestampfield is the the DATE/TIME field containing the date of the log entry and deleted will a log entries older than 31 days. Adapt to your local situation (database, table and field names and the desired time to keep log entries).

Related Topic