Page MenuHomeFreeBSD

script add -T fmt to print time-stamps
ClosedPublic

Authored by sjg on Mar 9 2022, 8:35 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 29, 8:45 PM
Unknown Object (File)
Nov 18 2024, 11:05 PM
Unknown Object (File)
Nov 18 2024, 8:53 PM
Unknown Object (File)
Nov 15 2024, 3:30 AM
Unknown Object (File)
Nov 5 2024, 11:07 PM
Unknown Object (File)
Nov 5 2024, 7:00 PM
Unknown Object (File)
Oct 21 2024, 7:59 PM
Unknown Object (File)
Oct 1 2024, 4:19 AM

Details

Summary

script -r is useful for recording time-stamps of when output
happened. With -T, rather than playback the script in real-time
we simply print the time-stamps to show when the output happened.

This is very useful for example, for analyzing boot time activity.

If the fmt provided contains no % characters the default
%n@ %s [%Y-%m-%d %T]
is used, which lends itself to analysis by tools as well as humans.

Sponsored by: Juniper Networks, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sjg requested review of this revision.Mar 9 2022, 8:35 PM
rpokala added inline comments.
usr.bin/script/script.c
94

That %n forces a newline, yes? To ensure that the timestamp line starts with e.g.

@1646858622 [2022-03-09 12:43:42]

even if the preceding line was incomplete and didn't include a newline?

allanjude added a subscriber: allanjude.
allanjude added inline comments.
usr.bin/script/script.1
41

This should go in the 2nd section of the synopsis with -p shouldn't it? You don't use -T while recording, only while playing back

45–46

This is where -T would go I think, since it implies -p anyway

This revision is now accepted and ready to land.Mar 9 2022, 8:51 PM
This revision now requires review to proceed.Mar 9 2022, 9:29 PM
sjg marked 2 inline comments as done.Mar 9 2022, 9:29 PM
sjg added inline comments.
usr.bin/script/script.c
94

Yes, the -r data may be single char at a time so you want a newline before each time-stamp for a readable result. Eg.

$ script -T - /tmp/tboot.log | head

@ 1646852915 [2022-03-09 11:08:35] Connected

@ 1646852916 [2022-03-09 11:08:36] 
root@bhyve:2# 
@ 1646852917 [2022-03-09 11:08:37] r
@ 1646852917 [2022-03-09 11:08:37] e
@ 1646852917 [2022-03-09 11:08:37] b
@ 1646852918 [2022-03-09 11:08:38] o
@ 1646852918 [2022-03-09 11:08:38] o
This revision was not accepted when it landed; it landed in state Needs Review.Mar 9 2022, 9:33 PM
This revision was automatically updated to reflect the committed changes.