Automated recordings deletion

I understand how the parameters work. I just don’t know where I put in that string.

find /var/spool/asterisk/monitor/ -name “*.wav” -mtime 30

Did you not interpret that to be the " command to be executed" on the link I sent ?

[root@localhost ~]# crontab -e -u root
crontab: installing new crontab
[root@localhost ~]# crontab -l

  • *     2     *     *        /var/spool/asterisk/monitor/
    

[root@localhost ~]#

I tried deleting everything after 2 days to make sure it was working, (right now theres only a month worth of data in there) but everything is still there.

it didn’t give me any errors this time. Hopefully I’m getting closer.

You are missing a lot here , that job would send the owner of that cronjob an email at midnight on the 2nd day of every month and every minute for the next 1439 minutes the issue of your command “/var/spool/asterisk/monitor/”

The content of that email would likely be

“sh: /var/spool/asterisk/monitor/: is a directory”

because it is not a valid command

Sorry to resurrect this, but in case this helps someone else
-mtime +30
For all files modified 30 days or more ago. -mtime 30 (no plus sign) matches all files modified only 30 days ago (not 29 days, not 31 days).

Here’s my cronjob: it deletes recordings 90 days or older daily at 1:15am

crontab -e
15 1 * * * find /var/spool/asterisk/monitor/ -name “*.wav” -mtime +90 -delete >/dev/null 2>&1

1 Like

Thank you all for providing information on how to automatically delete recordings. However, the method will leave behind a lot of empty folders. Any way to also delete those empty folders as well?

From bash

find /var/spool/asterisk/monitor/ -type d -empty -delete

1 Like

Perfect. Thank you.