LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Is it food have find command running in cron every day once to delete older files (https://www.linuxquestions.org/questions/linux-newbie-8/is-it-food-have-find-command-running-in-cron-every-day-once-to-delete-older-files-4175535038/)

xombboxer 02-25-2015 04:28 AM

Is it food have find command running in cron every day once to delete older files
 
I need to clean-up some folder. I have a cron job which uses find command to find and delete 25 days older file.

Code:


find $FOLDER_PATH/$FOLDER -depth -regex  ^$FOLDER_PATH/$FOLDER/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ -type d -mtime +25  -exec ls -ld {} \;  >> /tmp/deleted_folders.log

When this running it occupies 1-3% of cpu. And it may take longer time based on the folder size.

Is it ok to have find command running as cron job ?

jpollard 02-25-2015 05:25 AM

nothing wrong with it

unSpawn 02-25-2015 08:25 AM

Nothing wrong with that cron job except for a whiff of wheel reinvention aka NIH syndrome.
Also see 'tmpwatch'.

jpollard 02-25-2015 05:50 PM

Quote:

Originally Posted by unSpawn (Post 5323109)
Nothing wrong with that cron job except for a whiff of wheel reinvention aka NIH syndrome.
Also see 'tmpwatch'.

Well, it could also be said that tmpwatch was a NIH reinvention - as find was done first. :)

xombboxer 02-26-2015 12:15 AM

Thanks guys, Got to know 2 new stuff


All times are GMT -5. The time now is 09:56 AM.