Linux/ts: Difference between revisions

From Omnia
Jump to navigation Jump to search
 
(5 intermediate revisions by the same user not shown)
Line 8: Line 8:
  ts  
  ts  


  -r # relative time ago (eg. 15m5s ago)
    # no parameter default  (eg. Aug 03 12:06:32)
  -i # incremental time
  -r # relative time ago (eg. 15m5s ago)
  -s # time since program start
  -i # incremental time since last log  (eg. 00:00:00)
  -m # monotonic clock
  -s # time since program start (eg "00:00:00")
  -m # monotonic clock (eg. Aug 03 12:06:32)
 
If you just want the hour/minute/second:
ts "%H:%M:%S"
  12:07:45 xxxxxxxxxxxxxxxxxxx
 
If you just want epoch timestamp:
ts "%s"
  1722712097 xxxxxxxxxxxxxxxxxxx


== Timestamp Output ==
== Timestamp Output ==


  tail -f /some/device | ts
  tail -f /some/device_or_log | ts -s
 
ref: [https://unix.stackexchange.com/questions/26728/prepending-a-timestamp-to-each-line-of-output-from-a-command]
 
== Rainbow Color Output ==
 
see [[Linux/lolcat]]
 
tail -f /some/device_or_log | ts | lolcat
 
== keywords ==

Latest revision as of 20:18, 3 August 2024

ts

ts adds a timestamp to the beginning of each line of input
The optional format parameter controls how the timestamp is formatted, as used by strftime(3)
The default format is "%b %d %H:%M:%S"
ts 
    # no parameter default  (eg. Aug 03 12:06:32)
-r  # relative time ago (eg. 15m5s ago)
-i  # incremental time since last log  (eg. 00:00:00)
-s  # time since program start  (eg "00:00:00")
-m  # monotonic clock  (eg. Aug 03 12:06:32) 

If you just want the hour/minute/second:

ts "%H:%M:%S"
  12:07:45 xxxxxxxxxxxxxxxxxxx

If you just want epoch timestamp:

ts "%s"
  1722712097 xxxxxxxxxxxxxxxxxxx

Timestamp Output

tail -f /some/device_or_log | ts -s

ref: [1]

Rainbow Color Output

see Linux/lolcat
tail -f /some/device_or_log | ts | lolcat

keywords