LinuxCommandLibrary

multitail

Monitor multiple log files simultaneously

TLDR

Tail all files matching a pattern in a single stream

$ multitail -Q 1 '[pattern]'
copy

Tail all files in a directory in a single stream
$ multitail -Q 1 '[path/to/directory]/*'
copy

Automatically add new files to a window
$ multitail -Q [pattern]
copy

Show 5 logfiles while merging 2 and put them in 2 columns with only one in the left column
$ multitail -s 2 -sn 1,3 [path/to/mergefile] -I [path/to/file1] [path/to/file2] [path/to/file3] [path/to/file4]
copy

SYNOPSIS

multitail [options] <file> [...]
multitail [options] -l <command>

PARAMETERS

-f
    Follow file growth; display new lines as they are added to the file(s).

-s <buffer_size>
    Set the scrollback buffer size in lines for each window. Defaults to 100.

-l <command>
    Execute a command and tail its standard output, treating it like a log file.

-sn <num_screens>
    Split the terminal into <num_screens> horizontal windows for viewing files.

-e <regex>,<color>
    Highlight lines matching the specified regular expression with the given color.

-i
    Ignore case when searching or matching patterns for highlighting or filtering.

-M
    Merge lines from multiple input files into a single chronological stream based on timestamps found in the logs.

-r
    Reverse the order of lines displayed, showing the newest lines at the top (similar to tac).

-q
    Do not exit if one of the input files disappears; continue monitoring others.

-j
    Jump to the end of the file(s) immediately upon starting, showing only the latest lines.

-w [<width>]
    Wrap long lines to fit the window width. If <width> is specified, wrap at that column.

-cS <scheme_name>
    Use a predefined color scheme for syntax highlighting (e.g., apache, syslog, postfix).

-v
    Display the program's version information and exit.

-h
    Display the help message and exit.

DESCRIPTION

multitail is a powerful command-line utility for monitoring log files and command output in real-time. It extends the functionality of the standard tail command by allowing users to view multiple files simultaneously in a single terminal window, similar to a tiling window manager for text. Users can split the screen horizontally or vertically, display files in separate columns or rows, and even merge log files based on timestamps. Beyond simple viewing, multitail offers advanced features such as syntax highlighting for various log formats, filtering lines based on regular expressions, and executing commands to monitor their output. It's an indispensable tool for system administrators, developers, and anyone needing to keep an eye on multiple dynamic text sources concurrently, aiding in debugging, system health checks, and security monitoring. Its customizable interface and robust feature set make it a versatile replacement for running multiple tail -f commands in separate terminal sessions.

CAVEATS

Resource-intensive: Monitoring a large number of very active log files, especially with complex regex highlighting, can consume significant CPU and memory.
Configuration complexity: While powerful, multitail's extensive options and configuration files can have a learning curve for new users.
Terminal dependency: Its display capabilities are tied to the terminal emulator, and rendering issues might occur with unusual terminal settings or fonts.

FILTERING CAPABILITIES

multitail allows users to filter lines out or in based on regular expressions using options like -E (exclude) and -P (include), enabling focused monitoring of relevant log entries.

INTERACTIVE MODE

While primarily used with command-line arguments, multitail supports an interactive mode where users can dynamically change display settings, search, and navigate through buffers using keyboard shortcuts.

CONFIGURATION FILES

For complex setups or permanent configurations, multitail supports configuration files (e.g., ~/.multitailrc) where users can define custom color schemes, filters, and window layouts.

HISTORY

multitail was created by Paul Slager and first released around 2002. Its development was driven by the need for a more advanced tail utility that could handle multiple log files simultaneously within a single terminal, addressing the inconvenience of opening numerous terminal windows or using complex shell scripts to monitor logs. It has since evolved, incorporating features like coloring, filtering, and merging, making it a staple tool for system administrators and developers.

SEE ALSO

tail(1), less(1), grep(1), awk(1), sed(1), watch(1)

Copied to clipboard