Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

914 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

20 Experts available now in Live!

Get 1:1 Help Now