Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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 2 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

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.