LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Find the directories which is older than x days delete and zip those directories (https://www.linuxquestions.org/questions/linux-newbie-8/find-the-directories-which-is-older-than-x-days-delete-and-zip-those-directories-4175475111/)

ramesh pagadala 08-29-2013 12:58 AM

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

Firerat 08-29-2013 01:33 AM

Code:

man find
Code:

man tar

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

is a start

TB0ne 08-29-2013 08:17 AM

Quote:

Originally Posted by ramesh pagadala (Post 5017965)
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.


All times are GMT -5. The time now is 07:54 PM.