If you have a reasonably active FusionPBX (or vanilla Freeswitch) installation and you allow users to keep voicemail on the server, you're probably seeing your voicemail storage grow and available disk space dwindle. I thought this would be handy to share.
Our ultimate goal is to move voicemail storage into the cloud, but this little snippet is helping us bridge the gap until we get there.
Most, if not all telco's I've seen have an expiry on their voicemails (i.e. the user can't just leave them there for an eternity), somewhere around 30-60 days. I came across the following which finds voicemail files that are older than a certain date with the option of deleting them.
Source: http://blog.ones-app.com/how-to-recursively-find-and-delete-files-from-server-after-certain-time/
(I've updated the voicemail directory based on our freeswitch/fpbx installs, best to check where yours are located).
If you want to simply list the voicemail files that are 30 days or older, use:
If you want to delete the voicemail files that are 30 days or older, use:
(THIS WILL DELTE FILES - BE CAREFUL)
If you want to change the number of days, simply change '-mtime +30' to for example' -mtime +60' for 60 days
Simply add this as a cron and run however often you need. We run our once a day early in the morning so as not to disrupt customers.
Will delete all voicemails older than 30-days, every 24 hours at midnight (server time).
cheers,
A
Our ultimate goal is to move voicemail storage into the cloud, but this little snippet is helping us bridge the gap until we get there.
Most, if not all telco's I've seen have an expiry on their voicemails (i.e. the user can't just leave them there for an eternity), somewhere around 30-60 days. I came across the following which finds voicemail files that are older than a certain date with the option of deleting them.
Source: http://blog.ones-app.com/how-to-recursively-find-and-delete-files-from-server-after-certain-time/
(I've updated the voicemail directory based on our freeswitch/fpbx installs, best to check where yours are located).
If you want to simply list the voicemail files that are 30 days or older, use:
Code:
find /var/lib/freeswitch/storage/voicemail -type f -name "msg_*" -mtime +30 -exec ls -lhtr {} \;
If you want to delete the voicemail files that are 30 days or older, use:
(THIS WILL DELTE FILES - BE CAREFUL)
Code:
find /var/lib/freeswitch/storage/voicemail -type f -name "msg_*" -mtime +30 -exec rm {} \;
If you want to change the number of days, simply change '-mtime +30' to for example' -mtime +60' for 60 days
Simply add this as a cron and run however often you need. We run our once a day early in the morning so as not to disrupt customers.
Code:
crontab -e
add:
0 0 * * * find /var/lib/freeswitch/storage/voicemail -type f -name "msg_*" -mtime +30 -exec rm {} \;
Will delete all voicemails older than 30-days, every 24 hours at midnight (server time).
cheers,
A