and it works fine. I’m looking for a way such as a bash or perl script that I can use to delete the recordings once they reach a certain age. I’ve seen scripts to do this for single directories, but the above code creates a somewhat elaborate directory structure in which the calls are stored. I found this code here http://www.panoramisk.com/99/asterisk-call-monitoring/en/ Any thoughts are welcome.
You can use the linux “at” command to schedule an action in the future
exten => s,n,System(echo rm //|at now + 14 days)
This is not a tested line but I have used this kind of lines it in the same way so I assume it will work. If you add this line the soundfile will be deleted over 2 weeks. If it doesn’t work try it without the echo at the beginning.
Do “man at” on the linux prompt for more info. I hope this is helpful
That works - thanks! I was familiar with the ‘at’ command but did not think about using it to schedule removal of the file right from extensions.conf - clever!
I have no idea if there are any limitations in the number of “at” action that can be scheduled. If this is an important feature my advice is to test this. It will work with 100 and probably 1000 scheduled action but I have no idea if it will work whith 1000 calls a day with a scheduled removal of 30 days (so 30.000 at actions will be scheduled) .
If there are limitations you can schedule one “rm” per day for the directory where the recordings of a specific day are stored. It just need some extra lines of coding.
With the asterisk “stat” command you can check if a directory is already there so the first call of a day can trigger the creation of the dir for the recordings of that day and can schedule the removing of that directory after the period of your choice. This way you avoid a to large number of scheduled “at” actions.
enter “core show function STAT” on the cli for info about the stat command
exten => s,n,Set(DIR_EXISTS=${STAT(d,/var/spool/asterisk/monitor/30-09-2008)}) ; example that checks if there is a 30th september dir