How to output with timestamp using ts

You might sometimes want to create a log of the output from a program. Going into the program and adding a timestamp for each print command might seem cumbersome or not possible. It is here that the tiny ts utility makes itself useful. Pipe any output through it and it prefixes a timestamp to each line. Pipe the output of a long-running program through it and then save it to a file and you have a log!

To get this program, install the moreutils package:

$ sudo apt install moreutils

To use it:

$ ./my-program | ts > log.txt

Tried with: MoreUtils 0.5 and Ubuntu 14.04


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s