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 15, 3:30 AM
Unknown Object (File)
Tue, Nov 5, 11:07 PM
Unknown Object (File)
Tue, Nov 5, 7:00 PM
Unknown Object (File)
Mon, Oct 21, 7:59 PM
Unknown Object (File)
Oct 1 2024, 4:19 AM
Unknown Object (File)
Sep 26 2024, 12:13 PM
Unknown Object (File)
Sep 21 2024, 2:35 PM
Unknown Object (File)
Sep 21 2024, 2:35 PM

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
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 44726
Build 41614: arc lint + arc unit

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

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.