housekeeping


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting housekeeping
# 1  
Old 04-28-2006
housekeeping

hey, I have to write a housekeeping script which would delete any files which are more than 10 days old, the file is named in such a fashion

MYTEST20060101_182239.txt
MYXML20060112_182879.xml
MYEXCEL20060113_546321.xls

If the current date is 20060112, then MYTEST20060101_182239.txt will be removed. Would anyone show me how? thanks
# 2  
Old 04-28-2006
Try something like this:
Code:
find /path/to/files -name \*`date +%Y%m%d`\*  -exec rm {} \;

TEST this first before you run it. It's looking for files that match :*20060428*
for today, April 28, 2006, for example.
# 3  
Old 04-28-2006
other than find

instead of using find (mtime which may be changed), is there any other way by simply use the timestamp within the filename? Thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

[Tip] Housekeeping Tasks Made Easy - User Home directories and Leftover Files

We have regularly questions about how to create users and user accounts. But regularly user accounts need to be deleted too. It is quite easy to delete the user account itself but usually the HOME directory of the user remains. It is good style to remove these directories but simply deleting... (3 Replies)
Discussion started by: bakunin
3 Replies

2. AIX

Housekeeping null 2>&1 in /dev

Hello, Does anyone know how to housekeeping the null 2>&1 file in /dev? its fill up my system, please help. Thanks :b: (3 Replies)
Discussion started by: only
3 Replies

3. HP-UX

Problems after filesystem housekeeping

I have noticed that after I clear up the /var filesystem, there are always problems. Does deleting the OLDsyslog.log file cause problems like missing directories and problems accessing crontabs? There were two situations where I faced problems. 1) Deleted OLDsyslog.log (Of course I created... (5 Replies)
Discussion started by: anaigini45
5 Replies

4. Shell Programming and Scripting

Housekeeping script

I have a directory ( eg. /tmp , there are many files in it , I would like to do the houskeeping job , can advise how to develop a script to do the following . 1) if the files are elder than 10 days in this directory , the extension is .txt , then move it to /tmp/tmp-txt , the same , if the files... (2 Replies)
Discussion started by: ust3
2 Replies

5. Shell Programming and Scripting

Housekeeping Not Working

Hi, I have a .ksh script which finds all the directories older than 84 days and tries to housekeep. Below is the command used find * -depth -type d -ctime +84 -exec rm -rf {} \; The above command lists all the directories ie child and parent directory in descending order which are more... (10 Replies)
Discussion started by: annamalai77
10 Replies
Login or Register to Ask a Question