Solved

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

Posted on 1999-01-25
4
301 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
  • 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
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.

762 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now