LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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
 
LinkBack Search this Thread
Old 08-29-2013, 12:58 AM   #1
ramesh pagadala
LQ Newbie
 
Registered: Aug 2013
Posts: 1

Rep: Reputation: Disabled
Find the directories which is older than x days delete and zip those directories


Hi All

1) i want delete the direcotries which is older than 3 months
ex. /opt/pat/phd in this phd directory daily created some directories and for each directory is having different files ex txt,log ect so i want remove all files also

2) i want compress the directories which is older than 3 months

ex./opt/pat/phd in this phd directory daily created some directories i think based on timestamp not exactly i want compress those directories which is older than 7 days.
please let me know if any one knows.

Thsnks in advance,
Ramesh
 
Old 08-29-2013, 01:33 AM   #2
Firerat
Senior Member
 
Registered: Oct 2008
Distribution: Debian Jessie / sid
Posts: 1,256

Rep: Reputation: 385Reputation: 385Reputation: 385Reputation: 385
Code:
man find
Code:
man tar

http://www.tldp.org/LDP/abs/html/

is a start
 
Old 08-29-2013, 08:17 AM   #3
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 13,766

Rep: Reputation: 2346Reputation: 2346Reputation: 2346Reputation: 2346Reputation: 2346Reputation: 2346Reputation: 2346Reputation: 2346Reputation: 2346Reputation: 2346Reputation: 2346
Quote:
Originally Posted by ramesh pagadala View Post
Hi All
1) i want delete the direcotries which is older than 3 months ex. /opt/pat/phd in this phd directory daily created some directories and for each directory is having different files ex txt,log ect so i want remove all files also

2) i want compress the directories which is older than 3 months ex./opt/pat/phd in this phd directory daily created some directories i think based on timestamp not exactly i want compress those directories which is older than 7 days.

please let me know if any one knows.
We'll be glad to help you...so post what you've done/tried so far, and tell us where you're stuck. Reading the man pages as Firerat suggested will help you, and I'll add to read the man page on the 'rm' command.

Pay particular attention to the "-*time" flags on the find command (mtime, ctime, atime), and the "-rf" flag on the rm command.
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Find out timestamp line and delete if it is older than particular/specific days using bash script nitya Linux - Newbie 9 03-02-2013 07:55 AM
[SOLVED] Attempting to delete files that are older than 90 days, but not directories caiphn Linux - Newbie 12 07-07-2012 07:11 PM
delete files when it's older 30 days Madison00 Linux - Newbie 8 01-07-2011 02:07 AM
[SOLVED] Delete old files older than 7 days rjo98 Linux - Newbie 3 09-18-2009 01:15 PM
Delete files older then 30 days stefaandk *BSD 1 01-07-2008 08:31 PM


All times are GMT -5. The time now is 11:21 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration