Page 1 of 1

Delete Recording under 100 seconds Cronjob

PostPosted: Wed Nov 29, 2017 9:10 pm
by chasejordan1
I am trying to set up a cronjob to delete ALL recording that are under 100 seconds, but for some reason google is not helping me?


Any suggestions?

VERSION: 2.14-643a
BUILD: 171126-1413
Single Server.

Re: Delete Recording under 100 seconds Cronjob

PostPosted: Fri Dec 01, 2017 12:21 am
by pargat
Hi,

For this you can schedule a cron job to execute a script that will run through the list of files and delete the files that are below the duration you require.

You will have to use command line tools like sox or mediainfo.

hope this helps.

Re: Delete Recording under 100 seconds Cronjob

PostPosted: Fri Dec 01, 2017 11:44 am
by blackbird2306
This is the script you are looking for (usually in directory "/usr/share/astguiclient"):
AST_CRON_purge_recordings.pl


Then you should make a few adjustments in this script, because it looks only for recordings with certain save statuses which are predefined:
# runs every day, goes through recordings older than a certain number of days
# and deletes those recordings that are not of a certain status
# default is 30 days old to remove non-sales
#
# put an entry into the cron of of your asterisk machine to run this script
# every day or however often you desire


Here is the place for save states:
Line23: $save_statuses = '|SALE|UPSALE|UPSELL|XFER|DNC|DROP|A1|A2|A3|A4|A5|A6|A7|A8|A9|';

Next the trick for your purpose at line 113 with an adjustment to only delete recordings that are less than 100 seconds:
Code: Select all
##### Get the lead_ids of all recordings that are not DELETED or NULL #####
$stmtA = "SELECT lead_id,recording_id,start_time,filename,location FROM recording_log where start_time < '$TDSQLdate' and start_time > '$FDSQLdate' and location IS NOT NULL and location NOT IN('','NOT_FOUND','NOT_FOUND_2','DELETED') and length_in_sec <= 100 LIMIT 5000;";


Very important: This will delete all recordings (30 days / LIMIT 5000 recordings) where the statuses are not defined in "$save_statuses" and where recording length is under 100 seconds. But if it's defined (e.g. SALE) then it will not be deleted even when it's under 100 seconds!
But you can also change $save_statuses to delete all of them:
$save_statuses = '||';