2

Is there a way to see how often a file is being updated?
I mean I need to see if the modification time of a file is updated in a dynamic way (same as tail shows if the file is updated in a dynamic way).
I can not use e.g. tail since the contents of the file are not appended, but overwritten and could be overwriten with the same value so I can not make a concusion.

Jim
  • 335
  • 2
  • 4
  • 8

3 Answers3

3

How about this:

watch -n 1 'stat /path/to/the/file'
quanta
  • 51,413
  • 19
  • 159
  • 217
3

You can use inotifywait to do this much more efficiently for example

inotifywait -e modify -m  --timefmt "%F %T" --format "%T %e" /tmp/fred/1

Will watch the file /tmp/fred/1 for modify events so updading it produces output like

2013-02-22 09:30:26 MODIFY
2013-02-22 09:30:26 MODIFY

You can log multiple events, change the time format (the timefmt takes strftime formatting) output to a file and daemonize e.g

inotifywait -o /tmp/watch.out -d -e modify -m  --timefmt "%F %T" --format "%T %e" /tmp/fred/1

so now you can just tail /tmp/watch.out.

user9517
  • 115,471
  • 20
  • 215
  • 297
1

You can also use 'audit' daemon /etc/audit/auditd.conf is configuration file for audit daemon /etc/audit/audit.rules contains audit rules

friendyogi
  • 39
  • 1
  • 1
  • 4