- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- housekeeping script
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
тАО12-08-2011 01:33 AM
тАО12-08-2011 01:33 AM
housekeeping script
I am not familiar with writing script , I would like to write a script to do the following housekeeping task
1) move the files that elder than 30 days in current directory to /tmp/30days ;
2) check the files in /tmp/30days , if any file elder than 60 days , remove it.
3) copy the files in /tmp/30days which are created on the first day of the month ( 1st of every month ) to /tmp/firstday , so that it keeps all first day files.
can advise what can i do ?
thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-08-2011 02:26 AM
тАО12-08-2011 02:26 AM
Re: housekeeping script
>1) move the files that older than 30 days in current directory to /tmp/30days
find . -type f -mtime +30 -exec mv {} /tmp/30days \;
>2) check the files in /tmp/30days, if any file older than 60 days, remove it.
find /tmp/30days -type f -mtime +60 -exec rm -f {} +
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-12-2011 05:01 AM
тАО12-12-2011 05:01 AM
Re: housekeeping script
Hi:
> 3) copy the files in /tmp/30days which are created on the first day of the month ( 1st of every month ) to /tmp/firstday , so that it keeps all first day files
(ll /tmp/30days | grep -E "Jan 1|Feb 1| ..." | awk '{print $9}') | xargs -i -t mv {} /tmp/firstday
rgs,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО12-12-2011 12:10 PM
тАО12-12-2011 12:10 PM
Re: housekeeping script
>> 3) copy the files in /tmp/30days which are created on the first day of the month
>(ll /tmp/30days | grep -E "Jan 1|Feb 1| ... ) |
(You don't really need those () for a subshell.)
And note these are really files modified on the first, not created. The latter time isn't kept on HP-UX.