Find N number of days old file on solaris


 
Thread Tools Search this Thread
Operating Systems Solaris Find N number of days old file on solaris
# 1  
Old 07-14-2009
Find N number of days old file on solaris

Hi,

Code:
bash-3.00$ ls -ltr
total 8471258
-rw-r--r--   1 mysql    mysql       1227 Jul  7 22:33 information_schema.sql
-rw-r--r--   1 mysql    mysql     479762 Jul  7 22:49 mysql.sql
-rw-r--r--   1 mysql    mysql    1974789 Jul  7 22:50 youconnect.sql
-rw-r--r--   1 mysql    mysql       1355 Jul 10 16:22 crms.sql
-rw-r--r--   1 mysql    mysql        531 Jul 11 11:43 prakash
-rw-r--r--   1 mysql    mysql    2163607718 Jul 12 23:40 12-07-09.sql
-rw-r--r--   1 mysql    mysql    2169037247 Jul 13 23:40 13-07-09.sql



bash-3.00$ find /mysql1/mysqlbackup/ -type f -mtime +1 -exec ls -l {} \;
-rw-r--r--   1 mysql    mysql       1227 Jul  7 22:33 /mysql1/mysqlbackup/information_schema.sql
-rw-r--r--   1 mysql    mysql       1355 Jul 10 16:22 /mysql1/mysqlbackup/crms.sql
-rw-r--r--   1 mysql    mysql     479762 Jul  7 22:49 /mysql1/mysqlbackup/mysql.sql
-rw-r--r--   1 mysql    mysql    1974789 Jul  7 22:50 /mysql1/mysqlbackup/youconnect.sql
-rw-r--r--   1 mysql    mysql        531 Jul 11 11:43 /mysql1/mysqlbackup/prakash
bash-3.00$ date
Tue Jul 14 15:03:15 IST 2009
bash-3.00$ uname -a
SunOS webcast 5.10 Generic_127127-11 sun4v sparc SUNW,SPARC-Enterprise-T5120


So here why 2163607718 Jul 12 23:40 12-07-09.sql this file is not showing
in above find command.

Aappreciated any inputs.

Thanks

Prakash GR
# 2  
Old 07-14-2009
Quote:
-mtime n
File was last modified n*24 hours ago. When find figures out how many 24-hour periods ago the file was last modified, any fractional part is ignored, so to match -mtime +1, a file has to have been modified at least two days ago.
This is from my man page for find.
# 3  
Old 07-14-2009
Hi,

Thx for your reply.

I backup these files on regularly basis (that is *.sql) and won't be modified and my requirement is check file in /mysql1/mysqlbackup/ directory if any files are more than 2 day it should delete.

How can i achive this.

Thanks

Prakash GR
# 4  
Old 07-14-2009
Try:

Code:
find /mysql1/mysqlbackup/  -name "*.sql" -type f -mtime +2 -exec rm -f {} \;

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to find a file that's modified more than 2 days ago but less than 5 days ago?

How to find a file that's modified more than 2 days ago but was modified less than 5 days ago by use of any Linux utility ? (4 Replies)
Discussion started by: abdulbadii
4 Replies

2. Shell Programming and Scripting

Find a string in file 5 days ago

Hi, I need to grep for a string "Color Yellow" in all log files dated 5 days back until today's date . So, as today is 20 Dec i need to find in all logs from 16th dec to 20 dec. Also, i need ls -ltre output for the files that have the "Collor Yellow" string. Below is my OS: ... (1 Reply)
Discussion started by: mohtashims
1 Replies

3. UNIX for Dummies Questions & Answers

Find all log files under all file systems older than 2 days and zip them

Hi All, Problem Statement:Find all log files under all file systems older than 2 days and zip them. Find all zip files older than 3days and remove them. Also this has to be set under cron. I have a concerns here find . -mtime +2 -iname "*.log" -exec gzip {} Not sure if this will work as... (4 Replies)
Discussion started by: saurabh.mishra
4 Replies

4. Shell Programming and Scripting

Subtract 2 date columns in .csv file and get output as number of days

Hi, I have one .csv file. I have 2 date columns present in file, column 2 and column 3. I need to calculate how many days exist between 2 dates. I am trying to subtract date column 2 from date column 3. Eg: my file look likes s.no, Start_date,End_Date 1, 7/29/2012,10/27/2012 2,... (9 Replies)
Discussion started by: Dimple
9 Replies

5. Shell Programming and Scripting

find file older than one month not by x days olds

Hi, I would like to ask about some question on the -mtime option in the find command. I want to move a log files older than one month and planning to used the find -mtime +30 but i have some clarrification does -mtime +30 or -30 refer to x days beyond or between so how about the month. suppose... (2 Replies)
Discussion started by: jao_madn
2 Replies

6. Shell Programming and Scripting

How to Find number of days in a month in mmddyyyy format?

Hi Guru's, I am working on a shell script from past a month and unable to get rid of automating while working with dates,here's what i have. inital_date=11012011 final_date=11302011 expected_output= has to be in below format PFB 11012011 11022011 11032011 * * * 11102011 * *... (9 Replies)
Discussion started by: Gaurav198
9 Replies

7. Shell Programming and Scripting

Find unix file created how many days ago?

i want to find unix file created how many days ago? (4 Replies)
Discussion started by: utoptas
4 Replies

8. Solaris

Find files older than x days and create a consolidated single tar file.

Hello, I need help in finding files older than x days and creating a single consolidated tar file combining them. Can anyone please provide me a script? Thanks, Dawn (3 Replies)
Discussion started by: Dawn Bosch
3 Replies

9. Shell Programming and Scripting

Find the file from 15 days ago

How can I get difference date between today and 15 days ago and all filename is was created before 15 days ago? It has to be korn shell script. Thanks. (2 Replies)
Discussion started by: YoungBlood
2 Replies

10. Shell Programming and Scripting

Find number of days and list out the dates in between

Hi All, Can unix cshell list out the number of days between 070201 and 070205 (format is yymmdd) and list out all the dates in between in similiar format. set startdate = `date '+%y%m%d'` #eg 070201 set enddate = `date '+%y%m%d'` #eg 070205 i would expect the number of days to be 5... (2 Replies)
Discussion started by: Raynon
2 Replies
Login or Register to Ask a Question