Viewing log files in real time is one of the most important tasks for system administrators. Typically, it is the end of the log file where new information is appended. Therefore the command tail -f LOGFILE is used. This document describes tail as well as other tools.
The Swiss Army knife for system administrators. The tail tool can be used for various purposes, the most common ones are
tail -n NUMBER FILEtail -f FILE.cat FILE|sort|uniq|tail -n 1In cases where more than one log file needs 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 advantage of multitail over tail is that if you open 2 or more log files with one command in one window, multitail will group the output, unlike tail. Installation is simple.
aptitude install multitail
Unfortunately, the command line options are different from tail, but some are similar.
multitail -n NUMBER FILEmultitail -f FILE.cat FILE|sort|uniq|maultitail -j -n 1 will not work.cd /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, you should consider using grc to colorize tail.
For mail logs, grc produces better color output, in my opinion, because it highlights some constructs, like the contents of round and square brackets, and the header of a syslog line is easily distinguishable from the rest.
aptitude install grc
grc| Version | Date | Notes |
|---|---|---|
| 0.1.2 | 2023-04-06 | Improve writing, typos |
| 0.1.1 | 2022-05-28 | Link to grc & grc repository, +History, mv ../Tools |
| 0.1.0 | 2022-05-27 | Initial release |