Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help With find

Status
Not open for further replies.

podsds

MIS
Nov 8, 2002
20
US
I am using the find command to gather files for archives using the -mtime option. I have wrriten the script it works well, but now I want to add another feature without too much rewite ... so I am looking for a way to find all files >= 0 when using -mtime. Looking at the man page ... this does not seem to be an option ... or is it?

Any ideas?



# ll
total 24
-rwxr--r-- 1 root root 3260 Apr 9 09:04 TEMPLATE.SH
-rwxr--r-- 1 root root 8060 Apr 9 09:29 archive_log.sh


# find /sysadmin/script -name *.\* -mtime +0 -exec ls -l {} \;


# find /sysadmin/script -name *.\* -mtime 0 -exec ls -l {} \;
-rwxr--r-- 1 root root 3260 Apr 9 09:04 /sysadmin/script/common/TEMPLATE.SH
-rwxr--r-- 1 root root 8060 Apr 9 09:29 /sysadmin/script/common/archive_log.sh


#


# find /sysadmin/script -name *.\* -mtime -0 -exec ls -l {} \;


 
Find -mtime n looks for files with data that was last modified n*24 hours ago. Using a -number is looking for files that have modification dates that are in the future. Seems that this would never find anything, but have seen computers that were installed with a bad time sync master that resulted in all of the installed files having timestamp dates in a year after 2399! One of the symptoms of this was that every incremental backups of the systems were always as large as the original full backup!

 
So you want to find every file older than right now? Why not just touch a file and then use the -newer option?

Code:
touch /tmp/TimeNow
find /sysadmin/script -name *.\* -newer /tmp/TimeNow  -exec ls -l {} \;

Wouldn't that work?

Allen
 
To ZaSter (TechnicalUser) ...
I don't think that's my problem here. Thanks

To JAFrank (TechnicalUser) ...

The -newer option would work, but ... there is always a but ...
I am trying to retrofit a new option into a script that was coded for different purpose and don't want to rework it that much. The newer option would force me to test if I am archiving an active directory where I want to capture currently created files or just archiving a directory where the only interest is archiving aged log files.

Thanks
 
I'm confused....How are you determining which directory to archive under your current system?

What exactly are you trying to determine from the -mtime +0?

Allen
 
Well ... I wrote a script to locate files older than somevariable days, -mtime +$AGE, see initial thread ... first I tar up & gzip the files, then I remove the based on -mtine +${REMOVE_AGE} I am using this to get rid of log log files.

Then I had a thought ... I could use this script to keep a tar achive of all my sysadmin scripts by passing 0 as the AGE and 999 as the REMOVE_AGE, but I noticed that file created the sameday as the script runs are not picked up so ...

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top