Mailinglist Archive: opensuse (1986 mails)
| < Previous | Next > |
Re: [opensuse] Timestamping pipe [Was: Attempting (and succeeding) to use my UPS]
- From: "Brian K. White" <brian@xxxxxxxxx>
- Date: Thu, 20 Nov 2008 22:57:25 -0500
- Message-id: <9C5C1535D1444ECD8201A47124172CFF@venti>
----- Original Message -----
From: "Brian K. White" <brian@xxxxxxxxx>
To: <opensuse@xxxxxxxxxxxx>
Sent: Thursday, November 20, 2008 10:18 PM
Subject: Re: [opensuse] Timestamping pipe [Was: Attempting (and succeeding) to
use my UPS]
The one most usefull to me would be time since command start.
#!/usr/bin/awk -f
BEGIN { S=systime() }
{
s=systime()-S
m=0
h=0
d=0
if (s>=60) { m=s/60 ; s=s%60 }
if (m>=60) { h=m/60 ; m=m%60 }
if (h>=24) { d=h/24 ; h=h%24 }
printf ("%04i:%02i:%02i:%02i: %s\n",d,h,m,s,$0)
}
I tested the various rollover points like this:
First, add something to the calculated seconds "s" to bring it close to a
rollover point, after s=systime() and before anything that uses "s":
s=systime()-S
# s=s+58 # add 2 seconds before 1 minute to test minute rollover
# s=s+3598 # add 2 seconds before 1 hour to test hour rollover
s=s+86398 # add 2 seconds before 1 day to test day rollover
m=0
h=0
d=0
if (s>=60) { m=s/60 ; s%=60 }
if (m>=60) { h=m/60 ; m%=60 }
if (h>=24) { d=h/24 ; h%=24 }
printf ("%04i:%02i:%02i:%02i: %s\n",d,h,m,s,$0)
Then echo/sleep/echo...
(echo this ;sleep 1 ;echo is ;sleep 1 ;echo a ;sleep 1 ;echo test) |tscat
unadulterated:
0000:00:00:00: this
0000:00:00:01: is
0000:00:00:02: a
0000:00:00:03: test
one minute rollover:
0000:00:00:58: this
0000:00:00:59: is
0000:00:01:00: a
0000:00:01:01: test
one hour rollover:
0000:00:59:58: this
0000:00:59:59: is
0000:01:00:00: a
0000:01:00:01: test
one day rollover:
0000:23:59:58: this
0000:23:59:59: is
0001:00:00:00: a
0001:00:00:01: test
--
Brian K. White brian@xxxxxxxxx http://www.myspace.com/KEYofR
+++++[>+++[>+++++>+++++++<<-]<-]>>+.>.+++++.+++++++.-.[>+<---]>++.
filePro BBx Linux SCO FreeBSD #callahans Satriani Filk!
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx
| < Previous | Next > |