Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

It is possible. Try the following:

tail -f /tmp/log.txt | awk '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; }'
share|improve this answer
If you're dealing with log files that you are creating, it may be better practice to have the logging program add timestamps to the log instead of the above – earthmeLon Nov 4 '11 at 15:21
Also this will only tell one the time tail outputted the line. To see this try tail --sleep-interval=300 somefile – waltinator Jan 22 at 15:42
Oops 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 – waltinator Jan 22 at 15:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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