- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: need forums suggestions/expert opinion
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2009 04:28 AM
тАО03-05-2009 04:28 AM
need forums suggestions/expert opinion
under /tmp/bu-logs directory there are following 5 directories
# ls /tmp/bu-logs
maaz ron kjames rts adn riz
inside maaz ron kjames rts adn riz there are directories for each day, e.g
# ls /tmp/bu-logs/maaz/
01-03-09
02-03-09
03-03-09
04-03-09
05-03-09
etc
each of the directory /tmp/bu-logs/maaz/01-03-09, contains some files
now I wrote a script that is suppose to deletes all those directories(under /tmp/bu-logs/maaz, /tmp/bu-logs/riz, etc) that are older than 30 days
#!/bin/bash
cd /tmp/bu-logs
for i in maaz ron kjames rts adn riz
do
find ./ -ctime +30 -exec rm -rf {} \;
done
exit
will the above code work ?
is there any mistake ?
please share your comments/suggestion
Regards
Maaz
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2009 05:15 AM
тАО03-05-2009 05:15 AM
Re: need forums suggestions/expert opinion
Also, I would use the -mtime.
So, the result will be:
find /tmp/bu-logs -type f -mtime +30 -exec rm -fr {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2009 06:21 AM
тАО03-05-2009 06:21 AM
Re: need forums suggestions/expert opinion
a more descriptive Subject when posting a
question.
> will the above code work ?
Test it and see?
If you have any doubts, and you wish to avoid
deleting the wrong files, then replace "rm"
with something like "echo", and look at what
the script would have done.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-05-2009 09:35 PM
тАО03-05-2009 09:35 PM
Re: need forums suggestions/expert opinion
> I don't know why you use a for loop in that case, you could just start at the
> parent directory.
Because in /tmp/bu-logs/maaz, there are directories for each day, e.g
/tmp/bu-logs/maaz/03-03-09
/tmp/bu-logs/maaz/04-03-09
.
.
and 03-03-09 only contains the files that was created on 03-March-2009. so I want to delete all those directories, under /tmp/bu-logs/maaz/ that are older then 30 days.
I myself found the bug ;)
find ./ -ctime +30 -exec rm -rf {} \; # BUG
but following works
find $i/ -ctime +30 -exec rm -rf {} \;
#!/bin/bash
cd /tmp/bu-logs
for i in maaz ron kjames rts adn riz
do
find $i/ -ctime +30 -exec rm -rf {} \;
done
exit
> Also, I would use the -mtime.
Thanks, for the suggestion/tip
Dear Steven Schweda
> My first comment/suggestion would be to
> use a more descriptive Subject when posting a question.
thanks for your kind suggestion... Forum(esp Steven Schweda) please accept apology from my side
> If you have any doubts, and you wish to avoid deleting the wrong files,
> then replace "rm" with something like "echo", and look at what the script
> would have done
Thanks
Thanks once again.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-06-2009 01:08 AM
тАО03-06-2009 01:08 AM
Re: need forums suggestions/expert opinion
You code will hurt nothing.
Test it.
I like Ivan's too.
Test his.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-09-2009 06:28 AM
тАО03-09-2009 06:28 AM
Re: need forums suggestions/expert opinion
Doing a loop or not, is the same. Jumping to each directory to find files older then 30 days is the same as finding files older than 30 days on the parent directory.
You could also specify a list of directories to find without a loop, for example:
find maaz ron kjames rts adn riz -type f -mtime +30 -exec rm -f {} \;