- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- quick script to houseclean old files
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
01-29-2002 06:25 AM
01-29-2002 06:25 AM
Their was a question that arose. We are beginning on a new Unix venture and our application developer needs to write a script to control old files. He needs to check the age of a group of files, if the age exceeds a certain # of days then perform a remove. How could we accomplish this.
Thanks!
-barry donovan
pfpc global fund services
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2002 06:32 AM
01-29-2002 06:32 AM
Re: quick script to houseclean old files
Delete dat files that have not been modified for 7 days.
find /the/dir -type f -name *.dat -mtime +7 -exec rm {} \;
man find
...jcd...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2002 06:37 AM
01-29-2002 06:37 AM
Re: quick script to houseclean old files
I am not sure if it resolve your problem but try to use next command (lets say we are interested in file located in folder /folder)
#find /folder -atime +30 -exec rm {} \;
it finds all files older than 30 days in /folder and erase it.
hope it help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2002 06:38 AM
01-29-2002 06:38 AM
SolutionTry something like this.
DIR=/home/mydir
find ${DIR} -type f -mtime +10 -name '*.dat' -exec rm {} \;
That will find all regular files (-type f) older than 10 days (-mtime +10) that end with '.dat' (-name '*.dat') and then call rm on that file.
Man find for details and make sure that you do something like -exec echo {} \; as a test before you substitute the rm command in the real thing.
Regards, Clay
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-29-2002 06:41 AM
01-29-2002 06:41 AM
Re: quick script to houseclean old files
Use the 'find' command with '-mtime' option.
For eg:
# find /test -xdev -type f -mtime +10 -exec rm {} \;
This will delete the files which are not modified within last 10 days from /test.
HTH,
Shiju