Okay, so I guess I will check for a command like older filename since I want to delete the files older than thirty days old. -----Original Message----- From: programmingblind-bounce@xxxxxxxxxxxxx [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of qubit Sent: Tuesday, June 29, 2010 11:28 PM To: programmingblind@xxxxxxxxxxxxx Subject: Re: A unix cron job question No Eileen -- read the man page for the find command -- there is an actual option -newer filename that evaluates to "true" when the current file being analyzed is newer than the file specified. By "newer" I mean that its modified date is more recent. You should get familiar with the find command. It's one of those commands that is like ls or sed or whatever that is extremely useful when you need to analyze files. --le ----- Original Message ----- From: "Lafond, Eileen" <Eileen.Lafond@xxxxxxxxxxx> To: <programmingblind@xxxxxxxxxxxxx> Sent: Tuesday, June 29, 2010 5:11 PM Subject: RE: A unix cron job question Thanks for the code. I went through it and it makes sense to me. The part that says 'newer somefile' is apparently the place where I would put the calculation for determining the files that are over thirty days old. I don't know how to create that code. The original file name has the name of the data base and the name of the cron and the date created as the following: mydate="`date +"%m%d%y%H%M"" What would be the simplest way to determine the files that are over thirty days old? Thanks for any help, Eileen La Fond Work Phone: (206) 386-0011 -----Original Message----- From: programmingblind-bounce@xxxxxxxxxxxxx [mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of qubit Sent: Friday, June 25, 2010 6:47 PM To: programmingblind@xxxxxxxxxxxxx Subject: Re: A unix cron job question try the find command for F in `find directory -type f ! -newer somefile -print`; do echo "deleting $F"; rm $F done hope I'm remembering right -- I used to be a wild and crazy script writer. Happy hacking. --le ----- Original Message ----- From: "Lafond, Eileen" <Eileen.Lafond@xxxxxxxxxxx> To: <programmingblind@xxxxxxxxxxxxx> Sent: Friday, June 25, 2010 5:29 PM Subject: A unix cron job question We run many cron jobs daily that create a log file per cron job. This creates many log files over time. I think that we have about 33000 files right now. I am trying to create a cron job that will run once a month and delete all the log files that are more than thirty days out. I am trying now just to put the specification document together and I am having a difficult time with the details of the code. I was thinking of using the following: mydate="`date +"%m%d%y%H%M"" I cannot figure out how to write the code to go thirty days back and when I get that, I will then create a delete statement to delete the rest of the files. Does anyone have any idea as to how I can use the mydate above to figure out thirty days bac? Or am I doing this the wrong way and there might be an easier way to do it? Thanks for any help. Eileen La Fond Work Phone: (206) 386-0011 Email: Eileen.lafond@xxxxxxxxxxx __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind __________ View the list's information and change your settings at //www.freelists.org/list/programmingblind