2

In our production servers(AIX)there are multiple API calls which made every micro seconds and those API call details will be appended in an log called ins.log. On the other hand, we are using this data from the log to publish in a dash board so we will take the log file which got updated in the last 5 minutes using the command:

find . -type f -name ins.log -mmin -5

Without -mmin, the command finds the file, and you could see the modification time of the file is recent:

$ date
Tue Aug 29 18:34:54 +08 2023
$ find . -type f -name ins.log | xargs ls -l
-rw-r--r--    1 123456  123grp        74356 Aug 29 18:34 ./ins.log

But when I add -mmin it doesn't find the file.

$ date
Tue Aug 29 18:35:41 +08 2023
$ find . -type f -name ins.log -mmin -60

For example

  • if the ins.log get updated at 3:15 and the system date is 3:15 and the script runs at 3:15 then the ins.log which updated at 3:15 not coming in the output
0

1 Answer 1

6

The documentation for find -mmin on AIX describes this as an expected effect:

Files that are modified after the find command start time are not taken into account

So because you are (very) frequently updating the file, such that it's updated after you started your find command, it will be omitted from the list.

The fix is described in the same notes paragraph:

when the find command is used within the unary NOT operator […], the files that are modified after the command start time are displayed until the value of n.

Following this detail, you should simply need to invert the test so that you can use !:

find . -type f -name 'ins.log' ! -mmin +59
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .