[asterisk-users] How to roll-over / move / rotate an Asterisk Master.csv call detail record (CDR) file every 15 minutes

Danny Nicholas danny at debsinc.com
Tue Dec 4 09:02:59 CST 2012


IIRC log rotate only rolls the files in /var/log/asterisk, not
/var/log/asterisk/cdr-csv

-----Original Message-----
From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Paul Belanger
Sent: Tuesday, December 04, 2012 9:01 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] How to roll-over / move / rotate an Asterisk
Master.csv call detail record (CDR) file every 15 minutes

On 12-12-04 12:59 AM, Earl Ruby wrote:
> If you are trying to provide CDR files to a billing service, such as 
> WebCDR.com, you need to provide files containing your latest call data 
> every 15 minutes or so. I wrote a script and a cron job that will 
> create a new CDR file every 15 minutes with the latest CDR records, 
> without interrupting call flow. You do not need to make any changes to 
> your Asterisk configuration to use these scripts.
>
> There are two files that you need to install on your Asterisk server:
>
> asterisk-cdr-rollover.sh - A bash shell script. Copy this file into 
> /usr/local/sbin. This script moves the file 
> /var/log/asterisk/cdr-csv/Master.csv to a new file named 
> /var/log/asterisk/cdr-csv/cdr-YYYYMMDDHHMISS.csv, where YYYYMMDDHHMISS 
> is the current time. A new zero-byte Master.csv file is created using 
> the default umask of the user running the asterisk process. Asterisk 
> will start writing to the new Master.csv file at the end of the next call.
>
> asterisk-cdr-rollover - This is a cron job. Copy it into /etc/cron.d 
> and it will run the /usr/local/sbin/asterisk-cdr-rollover.sh script 
> once every 15 minutes.
>
> The cron job is set up to run as the user "asterisk". If you are 
> running asterisk as "root" or some other user name, edit the 
> asterisk-cdr-rollover cron job and change the name of the user running 
> the script to the same name as the user running the asterisk process.
>
> The latest versions of these two files can be downloaded from GitHub:
> https://github.com/earlruby/asterisk-cdr-rollover.
>
>
Why not use logroate?

$ man logrotate

--
Paul Belanger | PolyBeacon, Inc.
Jabber: paul.belanger at polybeacon.com | IRC: pabelanger (Freenode)
Github: https://github.com/pabelanger | Twitter: 
https://twitter.com/pabelanger

--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com -- New to
Asterisk? Join us for a live introductory webinar every Thurs:
               http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users




More information about the asterisk-users mailing list