My bad memory. -mtime -1 does mean less than one day ago, +1 means more
than one day ago.
But it is still junk. I can’t even understand the manual here, but for
times it says:
“File was last accessed n*24 hours ago. When find figures out how many
24-hour periods ago the file was last accessed, any fractional part is
ignored, so to match -atime +1, a file has to have been accessed at least
two days ago.”
I think “more than” means strictly > and not >=, so it needs a whole extra
24 hours to trigger. Personally, where it matters to me, I tend to stat
(istat in AIX) the file and get the seconds, and compare it with the
seconds returned now from date ‘+%s’. If you have seconds, you can figure
your own days arithmetically.
Also, +1 is not yesterday. It counts hours. So if you run your find -mtime
+1 at 15:30 on Tuesday, it selects files that were last updated before
15:30 on Monday. Part of yesterday is in and part is out.
… Linux has (but AIX does NOT) a -mmin option that counts in Minutes.
… Linux has (but AIX does NOT) a -daystart option that counts time from
00:00 of Today, rather than from current wall time. So it does count
distinct days without overlap.
It would be a whole lot easier for everybody if your files showed up in
directories with names like:
/u04/CSPRD/pdf/2017_10_17/whatever
or you could just make the directories and have /u04/CSPRD/pdf be a link to
today’s, updated by a cron job at midnight.
Then you could just compress the last directory but two, archive the last
directory but seven, and remove the last directory but 30. You don’t have
to worry about dates, whole days, finding stuff and all that junk.
And as Dan notes, directories get a modified timestamp when they are
themselves modified. If you have a tree, then creating a file only modifies
the immediate directory. And removing a file also marks the tree as
modified, even though every file left in it is now much older than the
directory itself.
Files and directories can also be touched – a fake modification – and the
timestamp can be set to any date you want, past or future. File system
timestamps are completely useless and unreliable except in carefully
regulated areas (like source repositories and release systems).