Help with cleanup!

Status
Not open for further replies.

taptech

Member
Mar 6, 2017
50
10
8
Hi guys,

I was hoping someone could help share a script with me. I'm interested in the following tasks:

1) Remove CDR entries that are older than x amount of days
2) Batch convert recordings to mp3 using lame or sox (or something else!)

Are there any other maintenance routines that you guys are using?
 

yukon

Member
Oct 3, 2016
138
14
18
For part 1:
Code:
## /bin/su -l postgres -c "/bin/echo \"delete from v_xml_cdr where start_stamp < (CURRENT_DATE - INTERVAL '90 day')::date;\" | /usr/bin/psql fusionpbx"

I have that as a line in my nightly backup scripts and just deletes everything older then 90 days.
 

taptech

Member
Mar 6, 2017
50
10
8
Great, thank you yukon. Can I just add this as a line in crontab or should I make it an executable script that is run via cron?

EDIT: you can disregard this post, I read your post more carefully and decided to do just what you had, and add this to my backup script. Thanks again!
 
Last edited:

taptech

Member
Mar 6, 2017
50
10
8
For MP3 conversion, I have this script working on my test vm. I would like to get it to work recursively, so that I can set the path to a domain and let it convert all of the wav files to mp3. Any hints?

Code:
LAMEOPTS="-b 48"
for DIRECTORY in /var/lib/freeswitch/recordings/192.168.195.65/archive/2017/May/02/*; do
if [ -d "$DIRECTORY" ]; then
echo "$DIRECTORY";
for FILE in "$DIRECTORY"/*.wav ; do
OUTNAME=`basename "$FILE" .wav`.mp3;
echo "$FILE" "$DIRECTORY"/"$OUTNAME";
lame $LAMEOPTS "$FILE" "$DIRECTORY"/"$OUTNAME";
rm "$FILE";
done
fi
done
 

taptech

Member
Mar 6, 2017
50
10
8
I ended up doing this, which is most likely not the most elegant solution, however it does offer some nicety in that I know it will only run into the day of month directory and no deeper. Not sure why there would be anything else in there, but who knows!

This seemed to work fine on my test vm and offered up about 10x reduction in file size.

Code:
LAMEOPTS="-b 48"
for DIRECTORY in /var/lib/freeswitch/recordings/192.168.195.65/archive/* /var/lib/freeswitch/recordings/192.168.195.65/archive/**/* /var/lib/freeswitch/recordings/192.168.195.65/archive/**/**/* /var/lib/freeswitch/recordings/192.168.195.65/archive/**/**/**/*; do
if [ -d "$DIRECTORY" ]; then
echo "$DIRECTORY";
for FILE in "$DIRECTORY"/*.wav ; do
OUTNAME=`basename "$FILE" .wav`.mp3;
echo "$FILE" "$DIRECTORY"/"$OUTNAME";
lame $LAMEOPTS "$FILE" "$DIRECTORY"/"$OUTNAME";
rm "$FILE";
done
fi
done
chown -R www-data:www-data *
 

taptech

Member
Mar 6, 2017
50
10
8
Basically just to save CPU time during calls. I wasn't sure how the encoding would effect call quality, and this seemed like a good way to avoid that. The system is a dual core droplet from DO with up to 10 concurrent calls, so probably not a problem... What do you think?

Also, I don't know how to record directly to MP3! :)
 

taptech

Member
Mar 6, 2017
50
10
8
Thanks Digi, I'll run that on my test box and compare to the one that I have above. Can you comment on the differences?
 
Status
Not open for further replies.