This command in my .sh script is supposed to look in /home/backup/VBtest for .sql.gz files and remove any older than 5 days:
find /home/backup/VBtest/*.sql.gz -mtime +5 -exec rm {} \;
But it doesn't. It gives me no warnings, no errors, just a silent fail. I am running it on CentOS 6.6.
EDIT - after comment suggestions, I also tried this find '/home/backup/VBtest' -name '*.sql.gz' -mtime +5 rm {} \; and got find: paths must precede expression: rm. Also what is the argument for file creation time (as opposed to file modified time)?
-exec? Do you really mean to pass a literal list of file paths tofind? – Michael Homer Sep 04 '15 at 09:12-mtimeonly check for modification time. – cuonglm Sep 04 '15 at 09:14find /home/backup/VBtest' -name '*.sql.gz' ...(test before you put in the exec part). – Petr Skocik Sep 04 '15 at 09:15.sql.gzfiles in/home/backup/VBtest/or in a subdirectory? I suspect that the way you used the command, find won't try to search in subdirectories - it just looks at those files directly in/home/backup/VBtest/– Sep 04 '15 at 09:26-execbetween+5andrm:find /home/backup/VBtest -name "*.sql.gz" -mtime +5 -exec rm {} \;– Lambert Sep 04 '15 at 09:32