solaris + how to verify if file isn’t update more than XX min

0

how to verify if file isn’t update more than 55 min?

For example, the file IOstatDisk2.log not update since 18:00 And now the current time is 19:00

 solaris1a:/var/tmp ROOT # ls -ltr IOstatDisk2.log
 -rw-r--r--   1 root    other       6 Aug  2 18:00 IOstatDisk2.log

So in this case I will append the line

echo “new cycle - file isnt update more 55 min” >> IOstatDisk2.log

But if the last time stamp was less than 55 min then I will not append the line

 echo “new cycle - file isnt update more 55 min” >> IOstatDisk2.log
  • I work with solaris 8/9/10

maihabunash

Posted 2015-08-02T19:28:26.200

Reputation: 479

Answers

0

You could use the inotify tools. Inotifywatch can observe file(s) and send you messages when certain operations are done to those files (eg. creation, deletion, etc). So, each hour you could set a flag, and reset it with the call from inotify. An example from man inotifywatch:

Watching the `~/.beagle' directory for 60 seconds:

   % inotifywatch -v -e access -e modify -t 60 -r ~/.beagle
   Establishing watches...
   Setting up watch(es) on /home/rohan/.beagle
   OK, /home/rohan/.beagle is now being watched.
   Total of 302 watches.
   Finished establishing watches, now collecting statistics.
   Will listen for events for 60 seconds.
   total  access  modify  filename
   1436   1074    362     /home/rohan/.beagle/Indexes/FileSystemIndex/PrimaryIndex/
   1323   1053    270     /home/rohan/.beagle/Indexes/FileSystemIndex/SecondaryIndex/
   303    116     187     /home/rohan/.beagle/Indexes/KMailIndex/PrimaryIndex/
   261    74      187     /home/rohan/.beagle/TextCache/
   206    0       206     /home/rohan/.beagle/Log/
   42     0       42      /home/rohan/.beagle/Indexes/FileSystemIndex/Locks/
   18     6       12      /home/rohan/.beagle/Indexes/FileSystemIndex/
   12     0       12      /home/rohan/.beagle/Indexes/KMailIndex/Locks/
   3      0       3       /home/rohan/.beagle/TextCache/54/
   3      0       3       /home/rohan/.beagle/TextCache/bc/
   3      0       3       /home/rohan/.beagle/TextCache/20/
   3      0       3       /home/rohan/.beagle/TextCache/62/

I believe inotify as such may not be available on Solaris, but here's an article on an equivalent(?)

jcoppens

Posted 2015-08-02T19:28:26.200

Reputation: 629