Create database in asterisk

Hi

I use asterisk, I connect to database and I want to create tables in “cdr” database.

Everyday, I want to create new table automatically. For example, today 06/26/2009 and I want to create tables is cdr_20090626 in cdr database.

How to configure crontab -e? Or configure in mysql?

Thanks for help!

Write a shell script

make_cdr_table_daily.sh

#!/bin/bash

SQL_HOST="192.168.0.33"
SQL_USER="asterisk"
SQL_PASS="asterisk001"
SQL_BASE=“asterisk”

stdate=date +%Y-%m-%d
echo $stdate

echo "$(date) creating today’s cdr table "
mysql -h $SQL_HOST -u $SQL_USER --password=$SQL_PASS -D $SQL_BASE -B -e
“create table cdr_$(date) (id int(11), calldate datetime)”

echo "$(date) done, exit"
exit

change the its permission by
chmod +x make_cdr_table_daily.sh

Then add following entry to crontab

1 0 * * * /home/make_cdr_table_daily.sh >>/root/
make_cdr_table_daily.log 2>&1

It will execute the script at 00:01:00 every day.

Hope this helps

Thanks for helps.