Results 1 to 4 of 4
which command can i use to delete wav files older than 45 days
following one give error
[root@tekopbx ~]# find /var/spool/asterisk/monitor/ -iname '*.wav' -ctime +45 -exec rm -f {}\;
find: ...
- 02-04-2012 #1Just Joined!
- Join Date
- Jan 2007
- Posts
- 27
auto delete older den 45 days
which command can i use to delete wav files older than 45 days
following one give error
[root@tekopbx ~]# find /var/spool/asterisk/monitor/ -iname '*.wav' -ctime +45 -exec rm -f {}\;
find: missing argument to `-exec'
[root@tekopbx ~]#
- 02-04-2012 #2
You've forgotten to put a space inbetween {} and \;
The command should be:Code:find /var/spool/asterisk/monitor/ -iname '*.wav' -ctime +45 -exec rm -f {} \;
- 02-04-2012 #3
It might be a good idea to restrict the find to files only ( -type f ) and use -delete instead of -exec and rm.
Other than that, you need to decide to use ctime or mtime.
I usually use mtime, because: If the file has been modified, I probably want to keep it for a while.You must always face the curtain with a bow.
- 02-05-2012 #4
Typically we don't use -delete because if you have too many files, then it tends to kick back a “maximum arguments exceeded” error. By using -exec a single process of rm handles the removal of a single file, and that means that many thousands of files can be handled without much of a problem.
Edit: after I created 1,000,000 text files in a test dir, I ran find with the delete flag but I didn't find a problem with it. However, that doesn't mean that all versions of find won't have this problem, it just means that my particular version doesn't have this problem. Also the size of the files may be a factor as well and therefore I can't consider it a complete test. In the end it's really just a matter of personal preference.Last edited by Krendoshazin; 02-05-2012 at 12:36 PM.


Reply With Quote
