Cron Job - command to delete all .flv files every day
I have this command which I run every day via cron:
find /home/get/public_html/videos -daystart -maxdepth 0
-mtime +1 -type f -name "*.flv" |xargs rm -f
The problem is that it doesn't delete the .flv files in a directory that is 1 or more days old.
How can I fix the above command?
EDIT: Paul - the command "ls -l / home / get / public_html / videos" results in 2000+ files, but here are 2 of them that should be removed:
-rw-r--r-- 1 get get 3501188 Jan 4 15:24 f486cf0a2b6bb40e4c50c991785084131231104229.flv
-rw-r--r-- 1 get get 10657314 Jan 4 17:51 f5f1490ddaa11a663686f9d06fb37d981231112941.flv
+1
source to share
3 answers
Better to use -print0 for lookups and -0 in xargs if one file has an unusual name.
Also, you want to use -maxdepth 1 to find something in the specified directory.
-maxdepth 0 means it will only be found in the directories listed on the command line, it will not check the contents of those directories.
+3
source to share