crontab command

I searched online for a command that would delete any recordings that are 90 days old. But i don’t think its actually working, i posted what i have there. Just wanna know if the command i entered is correct. If its not, how close did i get to getting it correct. Here it is:
Code:


01 21 * * * find /var/spool/asterisk/monitorDONE/MP3 -mtime +90 -exec rm {} \;
01 20 * * * find /var/spool/asterisk/monitorDONE/FTP -mtime +90 -exec rm {} \;
01 22 * * * find /var/spool/asterisk/monitorDONE/ORIG -mtime +90 -exec rm {} \;

Thank you
Armando Mercado

Unless your find is really old – e.g.:

find /var/spool/asterisk/monitorDONE/ -mtime +90 -delete

otherwise yoy have to worry about -depth etc.

I guess {} need to be escaped, e.g.

find /var/spool/asterisk/monitorDONE/ORIG -mtime +90 -exec rm {} ;

Just try it…

Yeah you need to escape {} as {}.

When there could be lots of files, this is more efficient:

find /var/spool/asterisk/monitorDONE/ORIG -mtime +90 -print0 | xargs -0 -r rm -f

Also if there is a possibility of subdirectories which could be older than 90 days but should not be deleted, you would want to add -type f to the find.

Yeah you need to escape {} as {}.

Depends on the shell, and we were not given the complete crontab. Csh knows about {}.

Anyway what is wrong with the -delete argument? It is specifically for this sort of job, descends directories, only removes files, and is shell independent.

I didn’t criticise -delete.

Well the reason for this script in the crontab is for recordings. I am a newbie when it comes to linux, been working with linux for 6 months but the opensuse version that i am using does not have a desktop everything is done through command prompt. Its for a predictive dialer and i don’t want to keep recordings that are more than 90 days old. I thought i had the line of code correct but didn’t know notice it was not working till i saw the hard drive space increasing. Plus i backup all recordings to a backup server. Now its just a matter of which one to use -delete or the {}. Which would y’all recommend??

Thank you
MoNdO