krzykat
Telecom Strategist
- Joined
- Aug 2, 2008
- Messages
- 3,149
- Reaction score
- 1,239
Note: much of this was ripped from threads that @dicko contributed to.
It's nice to have recordings of files, but can kill a system if you forget to purge to them. (I literally found this out firsthand while in Cozumel on a cruise ship. Read panic mode).
Here's a nice little solution to the problem:
Create a file - we'll call ours purgeMON in the /etc directory and give it executable rights (755 will suffice)
This will execute grabbing the files in /var/spool/asterisk/monitor directory and organize them oldest first and deleting these files until it is less than 90% of the drive used.
It will then remove any empty directories inside of the monitor folder.
Now to make it automated, edit /etc/crontab and add the lines:
This will run this file every morning at 5:05am - and insure that you never run out of disk space because of CDR recordings in the monitor directory.
It's nice to have recordings of files, but can kill a system if you forget to purge to them. (I literally found this out firsthand while in Cozumel on a cruise ship. Read panic mode).
Here's a nice little solution to the problem:
Create a file - we'll call ours purgeMON in the /etc directory and give it executable rights (755 will suffice)
Code:
#!/bin/bash
while (( `df /|/usr/bin/tail -1|/usr/bin/awk '{print $5'}|/bin/sed 's/\%//'` > 90 ));do /bin/rm -f `/bin/find /var/spool/asterisk/monitor/ -name "*.wav" -ls | /usr/bin/awk '{print $11'} | sort -n | /usr/bin/head -n 1` ;done
find /var/spool/asterisk/monitor/ -empty -type d -delete
This will execute grabbing the files in /var/spool/asterisk/monitor directory and organize them oldest first and deleting these files until it is less than 90% of the drive used.
It will then remove any empty directories inside of the monitor folder.
Now to make it automated, edit /etc/crontab and add the lines:
Code:
# Purge Audio Recordings along with empty directories
5 5 * * * root /etc/purgeMON
This will run this file every morning at 5:05am - and insure that you never run out of disk space because of CDR recordings in the monitor directory.