Clearing Loganalyzer History

In this article, I’ll show you how to clear outdated logs from Loganalyzer.

We look at the source ID, for example, in my case it is Source1, its configuration is described at the end of the /var/www/loganalyzer/src/config.php file, specify it in the script, and also indicate the correct path to the directory and the time in seconds how long to store the history, for example 86400 is 24 hours, 2592000 is 30 days, 15552000 – 6 months:

#!/bin/sh
cd /var/www/loganalyzer/src/cron/
php ./maintenance.php cleandata Source1 olderthan 15552000

Let’s make the script file executable:

chmod u+x maintenance.sh

After that, it can be run manually or added to the /etc/crontab scheduler so that it runs automatically, for example, every night at 01:15:

15 1 * * * root /var/www/loganalyzer/src/cron/maintenance.sh >/dev/null 2>&1

I will also give an example of manually deleting records from the database:

mysql
show databases;
use Syslog;
show tables;
select count(*) FROM SystemEvents;
select count(*) FROM SystemEventsProperties;
select * FROM SystemEvents LIMIT 10;
DELETE FROM SystemEvents WHERE ReceivedAt LIKE '2021-02%';

See also my articles:
Installing Rsyslog + Loganalyzer + MySQL
Using and configuring CRON

Leave a comment

Leave a Reply