Viewing logfiles in real time is one of the primary task for system administrators. Usually it is the end of the log file were new information is appended. Therefore the command tail -f LOGFILE is used. This document describes tail as well as other tools.
The Swiss knife for system administrators. The tool tail can be used for various purposes, the most common ones are:
tail -n NUMBER FILEtail -f FILEcat FILE|sort|uniq|tail -n 1In cases more that one log file need to be monitored, many approaches have been implemented.
cd /var/log&&tail -f mail.{err,warn,info,log}tail per terminalscreen and tailtmux and tailOr one can use multitail
The advantages of multitail over tail is that if you open 2 or more logfiles with one command in one window, unlike tail multitail will group the output. Installation is easy.
aptitude install multitail
Unfortunately the command line options differ from tail, but some are similar.
multitail -n NUMBER FILEmultitail -f FILEcat FILE|sort|uniq|mailtail -j -n 1 will not workcd /var/log&&multitail -f mail.{err,warn,info,log}Some differences to tail are:
multitail session with q not CTL-Ctail, multitail is difficult to use in scriptsIf the color feature of multitail would be the only reason to switch from tail to multitail, then one should consider using grc to colorize tail.
For mail logs grc creates in my opinion better color outputs, because it highlights some constructs, like round and square brackets content and the header of a syslog line can be easily distinguished from the rest.
aptitude install grc
grc| Version | Date | Notes |
|---|---|---|
| 0.1.1 | 2022-05-28 | Link to grc & grc repository, +History, mv ../Tools |
| 0.1.0 | 2022-05-27 | Initial release |