Solved

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

Posted on 1999-01-25
4
310 Views
Last Modified: 2008-03-04
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.
0
Comment
Question by:snydero
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 7

Accepted Solution

by:
HalldorG earned 100 total points
ID: 2009407
for i in $(find /ckpjnl +ctime 30 | grep -v ".cnf$")
do
   rm -f $i
done
0
 
LVL 7

Expert Comment

by:HalldorG
ID: 2009408
for i in $(find /ckpjnl -ctime +30 | grep -v ".cnf$")
do
   rm -f $i
done
0
 
LVL 1

Author Comment

by:snydero
ID: 2009409
I had to use the mtime parm, not ctime to make it work sensibly.
Thanks for the expertise.
0
 

Expert Comment

by:JSchneider
ID: 7811659
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

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

724 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question