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?
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?
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).
Proper syntax for what @Sven said:
mysql -u database-userid -pdatabase-password -e “DELETE FROM SystemEvents WHERE ReceivedAt < date_add(current_date, interval -1 day)” database-name
This one will delete data older than one day. Use with crontab to your liking.