LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-25-2009, 12:49 AM   #1
elainelaw
Member
 
Registered: Jan 2008
Posts: 258

Rep: Reputation: 30
Housekeeping task


In my system , there are many large files are generated to the system time by time , I would like to do the housekeeping task to archive the files to keep the server clean but still can let the user to extract the files when they required , can advise if I have below requirement

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 \;
 
Old 08-25-2009, 04:49 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Why don't you just gzip (or bzip2) the files in-place?

Cheers,
Tink
 
Old 08-25-2009, 05:09 AM   #3
malekmustaq
Senior Member
 
Registered: Dec 2008
Location: root
Distribution: Slackware & BSD
Posts: 1,661

Rep: Reputation: 485Reputation: 485Reputation: 485Reputation: 485Reputation: 485
elainelaw,

Q -- "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 ."


Answer:
YEs you can either manually or automated. For automated tar and clean up you can use a simple script and schedule it to run along /etc/cron/monthly or weekly. Just read a little tutorial to learn about cron or anacron (latter is better) and simple script making. You can click to download and go over the TOC of this tutorial to find specific answers.

Hope it helps.

Good Luck.
 
Old 08-25-2009, 06:02 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,374

Rep: Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383Reputation: 2383
If you mean logfiles, see logrotate cmd http://linux.die.net/man/8/logrotate which is almost definitely already in use by your system.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Task bar no longer shows task Richard Rahl Linux - Newbie 3 04-12-2010 09:39 AM
'Housekeeping' with /etc/rc.d/rc.local_shutdown? andrew.46 Slackware 3 08-05-2008 07:59 PM
LXer: Housekeeping utilities for Debian packages LXer Syndicated Linux News 0 12-01-2006 04:21 AM
A source code housekeeping question Dewar Linux - General 1 12-11-2003 07:02 PM
Linux Housekeeping GtkUser Linux - General 6 02-03-2003 07:54 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:04 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration