LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 03-26-2020, 11:21 AM   #1
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Rep: Reputation: 177Reputation: 177
find -mtime not working


I am running 'find /backup/*-hourly.tar.bz2 -mtime +1', but get no results. My current date/time is 2020-03-26 12:19. If I list some of the older files in that directory I get:
Code:
-rw-r--r-- 1 root backup  498680817 2020-03-25 05:17 /backup/20200325051501-hourly.tar.bz2
-rw-r--r-- 1 root backup  495717033 2020-03-25 04:18 /backup/20200325041501-hourly.tar.bz2
-rw-r--r-- 1 root backup  503292281 2020-03-25 03:18 /backup/20200325031502-hourly.tar.bz2
-rw-r--r-- 1 root backup  503634015 2020-03-25 03:05 /backup/20200325030103-hourly.tar.bz2
I also tried 'find /backup -name \*-hourly.tar.bz2 -mtime +1'

Why is my 'find' not listing all of these files? What am I doing wrong?
 
Old 03-26-2020, 12:30 PM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Fractional parts are ignored, so files selected by "-mtime +1" would have to have a modification time at least 2 days ago, "2" being the smallest integer greater than "1". It's explained in the manpage, where the description for "-mtime" references the note under "-atime".
 
2 members found this post helpful.
Old 03-26-2020, 08:27 PM   #3
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Original Poster
Rep: Reputation: 177Reputation: 177
Ah, you are right. I did read the man page, but did not follow up on the note referencing -atime on rounding. Thanks.
 
Old 03-26-2020, 08:34 PM   #4
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Original Poster
Rep: Reputation: 177Reputation: 177
here's the solution:
Code:
find /backup/*-hourly.tar.bz2 -mmin +1440 -exec rm -v {} \;
 
Old 03-27-2020, 01:17 AM   #5
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,790

Rep: Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201
Or -mtime +0
 
1 members found this post helpful.
  


Reply

Tags
find



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find with -mtime is finding EVERYTHING since, not everything older than NobleOne Linux - Newbie 6 08-16-2017 07:50 AM
alternative command for "find -mtime " sspisharody Linux - Newbie 2 02-13-2009 04:41 PM
using find to compare file mtime with another file's mtime TheFueley Linux - Newbie 1 12-23-2008 08:06 PM
'find' gives different results when using -mtime with -print vs -exec BrianK Linux - General 1 12-08-2008 10:32 AM
mtime in find vs ls lslade Linux - Software 0 11-17-2005 01:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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

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
Open Source Consulting | Domain Registration