Can voicemail be auto-deleted after X days?

Ok, I understand that I can immediately delete the voicemail file in an “e-mail only” setup. However, I want to keep the voicemail file in the user’s mailbox for X number of days and then automatically delete it if they don’t. Why? Well, I need a “backup” that users can still access their voicemail messages by telephone occassionally without requiring them to log in and manually delete the messages themselves because primarily they get the e-mail audio attachment. Does anyone have any cron script ideas or can Asterisk already “cleanup” mailboxes automatically somehow? Can voicemail messages be set to auto-expire??

Not a specific option to do this. There is “delete” but it deletes it off the server after a voicemail is left which is for people that only listen to voicemail via email. You could easliy setup a cron script that deletes voicemails that are so many days old.

Here is a command that will call a script to delete lock files that are older than 2 minutes. Just change this and it should work.

find /var/spool/asterisk/voicemail/ -mmin +2 -name ‘.lock*’ -exec /scripts/asterisk_delete_locks {} +

Hi Angle

where is a copy asterisk_delete_locks script avaible?

it looks very useful.


Script I made thats on my pc :smile: I made it when there was that bizarre bug with voicemail locks which never was fixed but suddenly disappeared.

rm -f $1

What if I use a database to store the voicemail and then issue commands against that for FIND date < today + 30? Can Asterisk use MySQL to store all the user voicemails? How would I set that database up to avoid the .txt, .WAV, and .gsm files that I’d have to deal with in a cron job? I didn’t realize that each voice message had three files associated with each! Please help, I’m lost on this one…

You can set Asterisk up to store voicemail in the database. The find command is a linux command for the filesystem not for Mysql, so no find will not work on the database. However you could make a different script that deletes the voicemails out of the database.

Right! That’s what I’m thinking is that it would be easier (and cleaner) to issue a command against the database to automatically delete old voicemail after so many days of sitting in the database. But, how do I setup database use on Asterisk 1.4.2? Do I need to use whatever this RealTime thing is? Does the Asterisk add ons MySQL trick work on 1.4.2?

Yes it should work, you want to use the voicemail storage as it’s called.

There is another post in Asterisk General about storing voicemails on databases and there I said that it would be not a good idea to store the binary information (sound files) on the database but only the description/information about it. Is this what is done with the existing voicemail storage?

Current implementation stores the actual sound file into the database as a blob.

Is there any feedback about this? How it deals with a great number of users? I don’t store binary information on my db’s, only the path to the files. It is faster to read a file from the filesystem and makes the db lighter and faster.

What Asterisk does to play the voicemail back to a person is it will pull it down from the database and play it off the filesystem. When a voicemail is stored, it is written to the filesystem first and then pushed to the database after its done being recorded.

i have made a cron job to delete old voicemails from asterisk database, my problem now how to re-arrange messages after deleting old ones? any help?