Log CDR to file every few minutes

Hello,

I would like to log the CDR to a file (csv or other) every few minutes. Is this possible?
Or maybe could I just send the /var/log/asterisk/cdr-csv/master.csv? How can I be sure that I am not sending it while it is being written by asterisk?

Also I am using FreePBX

Best regards

Copy the content of Master.csv running an script on a cron job every 1 minute.

1 Like

Hello @ambiorixg12 thanks for your fast anwer. If I decide to send the master.csv would be a problem if i send the file while asterisk is writing into it?

If the file is not locked, and you can read it, this won’t be a problem and you are running the script every one minute, so probably you will be overriding the content

1 Like

thanks, I will try in the next few days

FreePBX, which isn’t covered here, doesn’t use text files; it write CDRs to a database.

To avoid a half written record, rename the file and pause, before actually copying it. Some logs also require that you signal the process, to cause it to close an re-open the file, but I don’t think this is true for CDRs; I think the file is opened for every batch written.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.