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.

1

3 Answers 3

3

How about this:

watch -n 1 'stat /path/to/the/file'
2
  • I see this:Modify: 2013-02-22 04:25:07.000000000 -0500 the timestamp would dynamically increase had the file been constantly updated, correct?
    – Jim
    Feb 22, 2013 at 9:26
  • Yes, just try it.
    – quanta
    Feb 22, 2013 at 9:27
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.

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.