- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: script for deleting 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
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
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
04-10-2012 02:34 AM
04-10-2012 02:34 AM
script for deleting files
Hi all,
I need to delete all files from one catalog. The main rule is - files older than sysdate - 7 days should be deleted. For instance, today is 10.04.2012.and all files older 03.04.2012 must be deleted. is it possible to have script for this situation? then i will use this script in cron job.
thanks and regards,
rustam2
- Tags:
- find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2012 02:55 AM
04-10-2012 02:55 AM
Re: script for deleting files
Try below command....
# find /catalog -atime +7 -exec rm -i {} \;
also try -ctime for findind files based on creation date
Was this post useful? - You may click the KUDOS! star to say thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2012 03:30 AM
04-10-2012 03:30 AM
Re: script for deleting files
Thanks Hiren!
So, if i'm going to delete files from catalog /tmp/test/ i have to to run:
# find /temp/test/ -atime +7 -exec rm -i {} \;
?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2012 03:43 AM
04-10-2012 03:43 AM
Re: script for deleting files
Yes.
Check man pages for find command for -atime and -ctime usage to suit your requirements.
_____________________________________
How to assign points? Click the KUDOS! star!
Was this post useful? - You may click the KUDOS! star to say thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-10-2012 03:05 PM
04-10-2012 03:05 PM
Re: script for deleting files
># find /catalog -atime +7 -exec rm -i {} \;
If you want speed and limit it to normal files, you would use "+":
find /catalog -type f -atime +7 -exec rm -f {} +
>also try -ctime for finding files based on creation date
Not hardly. -ctime is for inode change time. Creation date isn't saved on Unix systems.
You can use -mtime for modification time.
>if I'm going to delete files from directory /tmp/test/ i have to to run:
Yes, or:
find /temp/test/ -type f -mtime +7 -exec rm -f {} +