I always run tail -F
to keep an eye on a log in a terminal window. The log has a UTC date at the beginning of each entry:
[08-Jan-2013 16:24:22] Yo!
When I glance at my log window I need to know how old the entries are. I would prefer not to have to look at my local clock and do the math. So I figured it would be cool to have a real-time clock display in the window along with the tail
ouput.
What I came up with was to background a while
loop echo
ing the date
and a carriage return. When a log entry is written, tail
overwrites the clock.
while true; do echo -ne `date +"[%d-%b-%Y %H:%M:%S]"`"\r"; sleep 1; done &
log -F /path/to/log
This basically works but I'm concerned about what happens when outputs from tail
and date
produce output at the same time. I don't want my view of the log to be spoiled by the carriage return.
How would I multiplex these outputs together so that they can't collide? Is that a job for screen
or something else?
The log is on a remote Debian server. My workstation runs OSX. I'm connecting via SSH to run the script above.