[Asterisk-Users] Your thoughts..
Andrew Kohlsmith
akohlsmith-asterisk at benshaw.com
Sun Nov 16 07:34:13 MST 2003
> I think there are two ways of doing it.. Either I can create an AGI that
> will run on the "h" extension and will lookup the last entry that
> matches the account code of the call that just ended in the MySQL CDR
> and calculate the call cost immediately..
Use the database. I'd recommend Postgres myself but to each their own.
> What will the issues be if the Master.csv is being updated at the exact
> moment my cron job tries to move it? is there any file locking or a
> method of delaying Asterisk's write or the cron's move operation till
> the file is availible?
Cheat. do this:
mv Master.csv Master.old
do
sleep 1
fuser Master.old > /dev/null
while [ $? -eq 0 ]
when you mv a file (within the same filesystem) you don't change its inode;
if * is accessing the file it notices nothing. Now you simply wait for *
to close the file (man fuser) and it's all yours, since * will create
Master.csv if it can't find it. I throw the sleep in there simply to be
nice to the system.
Seriously though, if you're gonna be throwing this into a database anyway,
why not store it there in the first place??
Regards,
Andrew
More information about the asterisk-users
mailing list