How to clear our CDR table

Hi

My server is currently backing up a 2GB CDR database with about 4yrs of data, I would like to delete 2013 and older

Before I do anything, I would like to check that the below is still the safest way to clear out the CDR table

SSH to the server.
mysql
use asteriskcdrdb;
DELETE from cdr WHERE calldate < ‘2014-01-01 00:00:00’;

The above should delete anything older than the 1st Jan 2014?

I am running 2.11 - Asterisk 11 64-bit

1 Like

I have looked at this and have run the above command. It only took the database down about 200mb

On looking further it’s the CEL table within asteriskcdrdb that’s huge with almost 9 million rows!!

Could I run the following to sync it down to the same date range as the first post?

mysql
use asteriskcdrdb;
DELETE from cel WHERE eventtime < ‘2014-01-01 00:00:00’;

yes you can;

And also if you want to downsize your cel table my formula is;

DELETE from cel WHERE context=‘tc-maint’;

*** Please, take backup before trying this.

Thanks

Works a treat however with CEL logging disabled it’s still logging to the table. I’ve had to create a shell script to empty it every night.

My database is now down to 98mb, a HUGE difference!