I want to print the time when a probe is fired. After checking the Dtrace documents, I find the built-in variable: walltimestamp
. And the Dtrace script likes this:
pid$1::func:entry
{
trace(walltimestamp);
}
But the walltimestamp
is "The current number of nanoseconds since 00:00 Universal Coordinated Time, January 1, 1970.", so the output likes "1389583988106535481".
I think this isn't easy for user to understand and want the output likes "Mon Jan 13 00:00:00 2014". I have searched whether Dtrace provide functions like ctime
in C programming language, but nothing found.
Does anyone need to implement a function like ctime by himself? Or Is there any better method to display the time?
Use printf()
:
# dtrace -qn 'BEGIN {printf("%Y\n", walltimestamp); exit(0)}'
2014 Jan 13 08:37:56
#
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With