FreePBX – Convert Wav to GSM and clean /var/spool/asterisk/tmp/ folder Clean asterisk temp folder

Last updated on April 3rd, 2019 at 03:16 am

#!/bin/bash
for i in `find /var/spool/asterisk/tmp/ -name '*wav'`
    do
        final=${i:0:${#i} -6}.gsm
        echo sox  -r 8000 -c 1 $i $final
        sox -r 8000  -c 1 $i $final
       rm -rf $i
       rm -rf /var/spool/asterisk/tmp/*.sln48
       rm -rf /var/spool/asterisk/tmp/*.ulaw
       rm -rf /var/spool/asterisk/tmp/*.alaw
       chown -R asterisk /var/spool/asterisk/tmp
done

1. Save this script in clean_asterisk_temp.sh

2.

chmod 777 /clean_asterisk_temp.sh

3. Create cron job every day a 05:10AM

export VISUAL=nano; crontab -e
crontab -e
05 10 * * 0  /clean_asterisk_temp.sh
systemctl restart crond
+---------------- minute (0 - 59)
| +------------- hour (0 - 23)
| | +---------- day of month (1 - 31)
| | | +------- month (1 - 12)
| | | | +---- day of week (0 - 6) (Sunday=0 or 7)
| | | | |
* * * * * command to be executed
26 8 * * *