I'd like to know the time when line was appended when file is being tail -f
'ed.
Is it possible to configure tail
to do something like that?
It is possible. Try the following:
tail -f /tmp/log.txt | awk '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; }'
tail
outputted the line. To see this try tail --sleep-interval=300 somefile
Jan 22, 2015 at 15:42
tail
only pays attention to --sleep-interval
when it is not using inotify
. So my example above should be tail ---disable-inotify --sleep-interval=3000 -f somefile
Jan 22, 2015 at 15:55