Delete Files > 1 Month Old, How id it Done?

I need a script to run weekly which will delete files in the /ckpjnl directory and its subdirectories that
1) are more than 1 month old and
2) do not have an extension of '.cnf'
Were are using crontab for other jobs now.
Thanks.
LVL 1
snyderoAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
HalldorGConnect With a Mentor Commented:
for i in $(find /ckpjnl +ctime 30 | grep -v ".cnf$")
do
   rm -f $i
done
0
 
HalldorGCommented:
for i in $(find /ckpjnl -ctime +30 | grep -v ".cnf$")
do
   rm -f $i
done
0
 
snyderoAuthor Commented:
I had to use the mtime parm, not ctime to make it work sensibly.
Thanks for the expertise.
0
 
JSchneiderCommented:
I tried this example on FreeBSD. The problem I have is that if any of the file names have a space in them, they are parsed out seperately and then the $i parameter does not carry the entire filename. Is there a simple way to solve this?
0
All Courses

From novice to tech pro — start learning today.