gnomon
Run command and display output timestamps
TLDR
Use UNIX (or DOS) pipes to pipe stdout of any command through gnomon
Show number of seconds since the start of the process
Show an absolute timestamp in UTC
Use a high threshold of 0.5 seconds, exceeding which the timestamp will be colored bright red
Use a medium threshold of 0.2 seconds, exceeding which the timestamp will be colored bright yellow
SYNOPSIS
some_command | gnomon [options]
PARAMETERS
-s, --real-time
Display real (wall-clock) time instead of elapsed time from when gnomon started.
-f <FORMAT>, --format <FORMAT>
Specify the timestamp format using strftime-like directives. For example, %H:%M:%S for hour:minute:second.
-T, --no-time-display
Suppress the display of timestamps, effectively acting as a pass-through filter without any modifications.
-c <WHEN>, --color <WHEN>
Control color output. <WHEN> can be always, auto, or never. Defaults to auto based on terminal capabilities.
-t <WIDTH>, --term <WIDTH>
Set the terminal width for formatting output. Useful when output is redirected or piped to other tools with specific width requirements.
-r, --raw
Output raw lines without any formatting or timestamping. This is similar to -T but might imply other formatting suppression.
-h, --help
Display a help message and exit.
-v, --version
Display version information and exit.
DESCRIPTION
gnomon is a command-line utility designed to prefix timestamps to lines of standard input, then print them to standard output. It is particularly useful for monitoring long-running processes, scripts, or continuous logs where understanding the time elapsed between events or when specific lines appear is crucial.
By default, gnomon shows the elapsed time since the command started, but it can also display real (wall-clock) time. It supports customizable time formats, colored output, and is often used in pipelines (e.g., make | gnomon or tail -f logfile | gnomon). This helps in debugging, performance analysis, and simply keeping track of progress during lengthy operations, providing a clear chronological context to raw output.
CAVEATS
gnomon operates by processing its standard input line by line. This means it is most effective when used in a pipe with another command that generates output continuously or in discrete lines. Very long lines without newlines might be buffered and not timestamped until a newline character is encountered or the process finishes. Its primary role is output adornment and monitoring, not input manipulation or controlling the piped command.
COMMON USE CASES
gnomon is frequently used when running build processes (e.g., make | gnomon), long-running tests, or lengthy scripts to observe the time taken for each step, aiding in performance analysis and debugging. It's also invaluable for tailing log files: tail -f /var/log/syslog | gnomon -s will display new log entries with real wall-clock timestamps, providing immediate chronological context.
INSTALLATION
While not a core GNU utility, gnomon is widely available through the package managers of most modern Linux distributions (e.g., sudo apt install gnomon on Debian/Ubuntu, sudo dnf install gnomon on Fedora, brew install gnomon on macOS). It can also be installed directly via Rust's package manager with cargo install gnomon, provided Rust and Cargo are set up on the system.
HISTORY
gnomon is a relatively modern utility, primarily written in Rust, which aims to provide a fast, robust, and user-friendly way to add timestamps to command output. It emerged as a popular alternative to similar tools like ts from `moreutils`, leveraging Rust's performance and safety features. Its development started gaining traction around 2017-2018, and it has since been included in the package repositories of many popular Linux distributions, becoming a staple for developers and system administrators for its simplicity and effectiveness in monitoring long-running processes.