- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Housekeeping task
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
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
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
тАО08-25-2009 12:15 AM
тАО08-25-2009 12:15 AM
Housekeeping task
1) keep the files ( that the creation day is within 2 months ) in the system , remove the files are elder than 2 months .
2) keep all files that created on monthly end in the system .
I know tar -zcvf can achive the files and append the files to it , but is it possible also to use tar to keep the files are within 2 months ? if not , what is the best way to do the housekeeping in my case ? thx a lot
find . -type f -mtime +60 -exec tar zcvf {} file \;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2009 03:05 AM
тАО08-25-2009 03:05 AM
Re: Housekeeping task
#!/usr/bin/ksh
function roll
{
typeset x
name=$1
set -- $name.[0-9][0-9][0-9][0-9].gz
if [ $1 = $name'.[0-9][0-9][0-9][0-9].gz' ]
then
return 0
fi
x=${1%.gz}
typeset -i y=${x##*.}
typeset -i idx=$y
while [ $# != 0 ]
do
x=${1%.gz}
y=${x##*.}
if [[ y > idx ]]
then
idx=y
fi
shift
done
idx=idx+10001
typeset -i idx2=0
while [[ $idx != 10000 ]]
do
idx2=idx-1
n1=$name.${idx#1}.gz
n2=$name.${idx2#1}.gz
if [ -f $n2 ]
then
mv $n2 $n1
fi
idx=idx2
done
}
mkdir archive
find . \( -name archive -prune -type f \) -o -type f -mtime +60 |
while read a
do
roll archive/$a
mv $a archive.0000
gzip archive/$a.0000
done
and start this in a cron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2009 05:01 AM
тАО08-25-2009 05:01 AM
Re: Housekeeping task
Here's one that looks for specific filename, owned by specific user, & over xx days old:
find /dir1/dir2 \( -name -filename* -a -user johndoe \) -mtime +60 -exec mv {} /archive1/dir2 \+
...or you can end it with \; like you have.
Just a thought,
Rgrds,
Rita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2009 11:38 PM
тАО08-25-2009 11:38 PM
Re: Housekeeping task
thx replies ,
thx Laurent Menase 's work , but the method seems too complicate for me ..
Laurent Menase ,
your method move old file to archive dir , but can it handle the monthly file , if I want to archive the monthly file , what can i do ? thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-26-2009 12:24 AM
тАО08-26-2009 12:24 AM
Re: Housekeeping task
do you mean you want to keep all the files archived month/month?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-26-2009 12:37 AM
тАО08-26-2009 12:37 AM
Re: Housekeeping task
thx reply ,
what I want is just to keep the month end files ( eg. 31-Jan , 28-Feb , 31-Mar , 30-Apr , 31-May ... )
For simply , tar command can do this request ?
Thx
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-26-2009 02:40 AM
тАО08-26-2009 02:40 AM
Re: Housekeeping task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-26-2009 07:15 PM
тАО08-26-2009 07:15 PM
Re: Housekeeping task
if today is 29-Aug-09 , in the archive , the user can see the files from 29-Jun-09 to 29-Aug-09 and monthly files 31-Jan , 28-Feb , 31-Mar , 30-Apr , 31-May 30-
if today is 30-Aug-09 , in the archive , the user can see the files from 30-Jun-09 to 30-Aug-09 and monthly files 31-Jan , 28-Feb , 31-Mar , 30-Apr , 31-May 30-
if today is 31-Aug-09 , in the archive , the user can see the files from 1-Jun-09 to 31-Aug-09 and monthly files 31-Jan , 28-Feb , 31-Mar , 30-Apr , 31-May 30-
if today is 1-Sep-09 , in the archive , the user can see the files from 1-July-09 to 1-Sep-09 and monthly files 31-Jan , 28-Feb , 31-Mar , 30-Apr , 31-May 30-,30-Jun-09
├в
├в
if today is 1-Oct-09 , in the archive , the user can see the files from 1-Aug-09 to 1-Oct-09 and monthly files 31-Jan , 28-Feb , 31-Mar , 30-Apr , 31-May 30-,30-Jun-09 , 31-Jul-09