- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- how to delete old files including those in subdire...
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
Forums
Discussions
Discussions
Discussions
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
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
10-12-2009 10:27 PM
10-12-2009 10:27 PM
how to delete old files including those in subdirectory
Hi, i have a HP-UNIX 11.0 backup server that usr1/backuplog directory increasing in big size
1) how to check what program/process is writing logfile into backuplog dir daily?
2) how to delete old files in backuplog dir including those in subdirectory & keep only recent 7 days?
sorry, i'm new to HP-UNIX
thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2009 10:49 PM
10-12-2009 10:49 PM
Re: how to delete old files including those in subdirectory
lsof /your directory
>how to delete old files in backuplog dir
cd your directory
rm
if includes subdirectory
rm -R
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2009 10:51 PM
10-12-2009 10:51 PM
Re: how to delete old files including those in subdirectory
Look at what runs daily? "man cron"?
> 2) [...]
"man find", look for "-mtime".
> sorry, i'm new to HP-UNIX
Are you new to UNIX in general, or only to
HP-UX?
A Forum search for keywords like, say,
find mtime
should find many examples.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2009 10:54 PM
10-12-2009 10:54 PM
Re: how to delete old files including those in subdirectory
> rm
There's a difference between "delete old
files" and "delete log files".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2009 10:55 PM
10-12-2009 10:55 PM
Re: how to delete old files including those in subdirectory
a simple example:
find /your directory -name
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-12-2009 11:50 PM
10-12-2009 11:50 PM
Re: how to delete old files including those in subdirectory
sorry,i need to delete all old files (just keep recent 7 days) in backuplog dir & subdirectory (want to keep directory structure)
sorry, i'm new to unix in general
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2009 03:19 AM
10-13-2009 03:19 AM
Re: how to delete old files including those in subdirectory
OK then use this way:
first you have to go directory that your files there;
cd /directory
then if you will delete the old files they are older than 7 days just issue:
find /directory -name "*" -mtime +7 -exec rm {} \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2009 05:03 AM
10-13-2009 05:03 AM
Re: how to delete old files including those in subdirectory
If you want to do all files, no need for -name:
find /directory -mtime +7 -exec rm {} +
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2009 06:20 AM
10-13-2009 06:20 AM
Re: how to delete old files including those in subdirectory
> cd /directory
No good reason for this "cd", either, with
"/directory" in the "find" command.
Also, if you're unsure about what damage this
command might do, you can replace "rm" with
"echo", which is much safer. Then, if you
see that it finds the files which you wish to
remove, run it again with the real "rm".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2009 04:22 PM
10-13-2009 04:22 PM
Re: how to delete old files including those in subdirectory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2009 05:27 PM
10-13-2009 05:27 PM
Re: how to delete old files including those in subdirectory
find /dir_name | xargs ll -ld | sort -nrk5 | more
Thanks and Regards,
Din
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2009 07:16 PM
10-13-2009 07:16 PM
Re: how to delete old files including those in subdirectory
> "man find", [...]
Still a good idea.
What you might do is read some of these
responses. For example:
> Also, if you're unsure about what damage this
> command might do, you can replace "rm" with
> "echo", which is much safer. Then, if you
> see that it finds the files which you wish to
> remove, run it again with the real "rm".
In many cases, it's easier (and more
reliable) to _try_ something than it is to
ask how that thing will work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2009 08:22 PM
10-13-2009 08:22 PM
Re: how to delete old files including those in subdirectory
how to include deleting old files in subdirectory?
find /directory -mtime +7 -exec rm {} +
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2009 08:32 PM
10-13-2009 08:32 PM
Re: how to delete old files including those in subdirectory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2009 09:39 PM
10-13-2009 09:39 PM
Re: how to delete old files including those in subdirectory
>>how to include deleting old files in subdirectory?
Then you need to apply two commands instead of one see the example
1st command will store your all old files into /tmp/oldfiles and 2nd will delete all file which are not recently updated within 7 days
#find /directory -mtime +7 -exec ls -l {} \; >/tmp/oldfiles
#find /directory -mtime +7 -exec rm {} \;
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2009 10:54 PM
10-13-2009 10:54 PM
Re: how to delete old files including those in subdirectory
# find /usr1/backuplog -mtime +7 -exec ls -l {} \; >/tmp/oldfiles
# find /usr1/backuplog -mtime +7 -exec rm {} \;
# cd usr1/backuplog
# ls
friday monday saturday sunday thursday tuesday wednesday
# cd friday
# ls
924 comms conv corr1 dro ffg labels mdc reel workip xdata
# cd 924
# ls
XMIT0122.LOG XMIT0216.LOG XMIT0310.LOG XMIT0404.LOG XMIT0422.LOG
still didn't delete old *.LOG in subdirectory of backuplog dir. du -sk backuplog still show 15777040. /tmp/oldfiles 0 bytes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2009 10:56 PM
10-13-2009 10:56 PM
Re: how to delete old files including those in subdirectory
This is the default for find(1). Otherwise it is hard to not get subdirectories.
This is all documented under find(1).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2009 11:17 PM
10-13-2009 11:17 PM
Re: how to delete old files including those in subdirectory
What does ll(1) show for that directory and file? Perhaps those files aren't old?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2009 05:02 AM
10-14-2009 05:02 AM
Re: how to delete old files including those in subdirectory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2009 05:25 AM
10-14-2009 05:25 AM
Re: how to delete old files including those in subdirectory
command might do, you can replace "rm" with
"echo", which is much safer. Then, if you
see that it finds the files
You are right when it comes to be sure before deletion. .