Linux – delete files which modified time older than 7 days
find /filePath/* -mtime +7 -delete
or
find /filePath/* -mtime +7 -exec rm {} \;
Where “-mtime” parameter will look for file modified time older than “+7″ days. You may want to change “+7″ to longer days, for example “+30″ days, “+90″ days
“-exec” parameter allows you to call another command. The “{} \;” is required at the end.







find /filePath/* -mtime +7 -exec rm {} \; results in the error “find: missing argument to ‘-exec’
The same error ocurrs when I use the -f option with rm. Note I am not adding spaces between rm{}\; it just looks that way when I pasted here.