View source for Timestamp
Jump to:
navigation
,
search
=Generating Timestamps= I've run into compiled code (no source available) that did not timestamp debugging output. This created problems for troubleshooting. What's a mother to do? We're looking to do something like this: <pre> progam_being_debugged 2>&1 | timestamp_generator > badapp.log </pre> There are many ways to do this, "this" being "program_being_debugged". Here are the methods explored below: *shell *awk *daemontools (tai64n[local]) *ts (from moreutils; see "moreutils" page on this wiki) *perl Of course there are some other ways to do this: write a 'C' program (don't know if 'ts' is written in C or something else), try various other languages. However, the scope of this project was "quick & dirty" with the emphasis on quick. Nonetheless, I managed to carve out the time necessary to test the methods above. Note that when debugging, we often want to 'tail' the output to watch what's going on in realtime, and possibly use our monkey minds to attempt to correlate with external events. Like so: <pre> program_being_debugged 2>&1 | timestamp_generator | tail -f </pre> In this case, it's important to minimize buffering along the pipeline so that output gets to our optical sensors as quickly as possible. This can be done with the "unbuffer" command, which requires installation of the 'expect' package (expect-dev on some distros). ==Results== A simple shell script harness was used for the testing: <pre> example </pre> This was run on a machine under Ubuntu 14.10. Here are the results: ==shell== bash version 188.36user 779.17system 13:25.67elapsed 120%CPU (0avgtext+0avgdata 6072maxresident)k 0inputs+0outputs (0major+28033858minor)pagefaults 0swaps ==awk== awk version <pre> 6.49user 12.23system 0:12.42 elapsed 150 %CPU (0avgtext+0avgdata 6072maxresident)k 0inputs+0outputs pagefaults 0swaps ==daemontools== ==ts== ==perl==
Return to
Timestamp
.
Navigation menu
Personal tools
Log in
Namespaces
Page
Discussion
Variants
Views
Read
View source
View history
Actions
Search
Navigation
Main page
Community portal
Current events
Recent changes
Random page
Help
Toolbox
What links here
Related changes
Special pages
Page information