ts
Prepend timestamps to command output lines
TLDR
Add timestamps to command output
SYNOPSIS
ts [-imsu] [-r] [format]
DESCRIPTION
ts reads lines from standard input, prepends a timestamp to each line, and writes to standard output. It is part of the moreutils package and is useful for logging, debugging, and monitoring command output over time.
The default timestamp format is "%b %d %H:%M:%S" (e.g., "Jan 22 14:30:45"). Custom formats use strftime conversion specifications. Extended specifiers %.S, %.s, and %.T provide subsecond resolution.
The -s option shows cumulative time since ts started, useful for measuring total elapsed time. The -i option shows time between lines, helpful for identifying slow operations in pipelines.
The -r option converts existing timestamps in the input to human-readable relative times, supporting many common timestamp formats.
PARAMETERS
-i
Show incremental time elapsed since last timestamp-s
Show time elapsed since program start-m
Include milliseconds in timestamps-u
Use UTC time instead of local time-r
Convert existing timestamps to relative times (e.g., "15m5s ago")format
Custom strftime format (default: "%b %d %H:%M:%S")
EXAMPLES
Monitor log file with timestamps
CAVEATS
ts requires the moreutils package, which may not be installed by default. The command buffers output, which can cause slight delays when used with slowly producing commands. Timestamps reflect when ts receives each line, not when the original command produced it.
HISTORY
ts was written by Joey Hess as part of moreutils, a collection of Unix utilities. Moreutils was first released around 2006 to provide additional tools that complement the standard coreutils, filling gaps in common command-line workflows.
