The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help me clean this up scanner248 UNIX for Dummies Questions & Answers 1 10-15-2007 01:31 PM
Startup script to clean out trash can Andrek OS X (Apple) 4 10-19-2006 12:34 PM
writing script to clean up a directory ajaya Shell Programming and Scripting 0 04-26-2006 07:18 AM
Clean up /tmp at reboot Silver11 AIX 2 03-14-2006 11:23 AM
Clean an LV out of the ODM Wamland UNIX for Advanced & Expert Users 0 11-23-2004 12:44 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-17-2006
Registered User
 

Join Date: Mar 2006
Posts: 89
clean up script

I have a script which would monitor a given directory and delete any files which are older than 10 days. I was going to set the 10 crob jobs to perform this operation for 10 different directories (some are actually sub-directories), but my boss doesn't like that idea, so I need to do that in one script, besides of hard-coding all these directories, does anyone have any other idea? Thanks
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 07-17-2006
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,325
You could just hardcode the directory names in the script if you wanted... its just going to be ten lines. Then you could run the script as a cron job.
Now, if you are not comfortable with that, you could have a script that reads the directory names from a file and runs the find on that.
Code:
while read dirname; do
   find $dirname -type f -mtime +9 -exec # do whatever you want here
done < /path/to/list_of_dirnames
The second method will be preferable if the list of directories to clean is going to change often or grow larger over time
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:51 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0