How to clear CDR Database

Hello all,

I have what might be a how-to, but because I know that I don’t know, I’ll ask those who do first. Is this safe to run to clear out the CDR database?

I do the following:

  1. SSH to the server
  2. Type the following commands:

List databases:

Select the CDR DB:

List the tables in the database:

To view the columns:

To view the rows:

[code]mysql> select src,duration,dst FROM cdr WHERE duration >= 0;

To CLEAR the CDR Table:

For those wondering why I would even need to clear the CDR - we had been imaging our PBXes from whatever test box is in the office at the time. But now we are using a master image where the CDR is now cleared. But I still wanted to ask anyway, and if this is safe to do, I hope this helps others asking the same questions.

1 Like

I am not sure if this is the safe way but i did the same thing and it worked for me.

Thanks for the advice.

Thanks for your steps. I modified it slightly to simplify it and to only delete CDRs older than a date. Here are the steps:

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

In the example above any CDR before Nov 1 2013 will be deleted. Change the date to whatever date you would like to use.