* [gentoo-user] Finer grained date output.
@ 2005-08-20 2:07 Harry Putnam
2005-08-20 2:17 ` Marco Matthies
0 siblings, 1 reply; 6+ messages in thread
From: Harry Putnam @ 2005-08-20 2:07 UTC (permalink / raw
To: gentoo-user
This question is not gentoo specific but really a more general
question about date manipulation.
Like many people I use the `date' command to set file names that need to
be unique by using one of the specially formatted commands, to output
something like:
img_080905_103343.jpg
Which is img_$(date +"%m%d%y_%H%M%S").jpg or mnthdayyr_hrminsec
This is used in file renaming scripts or the like.
I want to find some tool that outputs a more fine grained reading.
Maybe adding milliseconds to output so that the unique names can be
generated in less than a second.
I know about perl scipting for this but wanted something like the
`date' command that is its own dedicated program.
Is there a unix tool that outputs a finer grain of time segments?
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] Finer grained date output.
2005-08-20 2:07 [gentoo-user] Finer grained date output Harry Putnam
@ 2005-08-20 2:17 ` Marco Matthies
2005-08-20 2:38 ` [gentoo-user] " Harry Putnam
2005-08-20 5:08 ` [gentoo-user] " Willie Wong
0 siblings, 2 replies; 6+ messages in thread
From: Marco Matthies @ 2005-08-20 2:17 UTC (permalink / raw
To: gentoo-user
Harry Putnam wrote:
> I know about perl scipting for this but wanted something like the
> `date' command that is its own dedicated program.
>
> Is there a unix tool that outputs a finer grain of time segments?
man date
look for nanosecond format, e.g.:
date +"%N"
Marco
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 6+ messages in thread
* [gentoo-user] Re: Finer grained date output.
2005-08-20 2:17 ` Marco Matthies
@ 2005-08-20 2:38 ` Harry Putnam
2005-08-20 2:58 ` Marco Matthies
2005-08-20 5:08 ` [gentoo-user] " Willie Wong
1 sibling, 1 reply; 6+ messages in thread
From: Harry Putnam @ 2005-08-20 2:38 UTC (permalink / raw
To: gentoo-user
Marco Matthies <marco-ml@gmx.net> writes:
> Harry Putnam wrote:
>> I know about perl scipting for this but wanted something like the
>> `date' command that is its own dedicated program.
>> Is there a unix tool that outputs a finer grain of time segments?
>
> man date
> look for nanosecond format, e.g.:
> date +"%N"
Ha .. Thanks.. has that been there a long time?
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] Re: Finer grained date output.
2005-08-20 2:38 ` [gentoo-user] " Harry Putnam
@ 2005-08-20 2:58 ` Marco Matthies
0 siblings, 0 replies; 6+ messages in thread
From: Marco Matthies @ 2005-08-20 2:58 UTC (permalink / raw
To: gentoo-user
Harry Putnam wrote:
> Ha .. Thanks.. has that been there a long time?
Dunno, I noticed it a few weeks ago -- probably has been there since
processors have had frequencies above a GHz i suppose.
Marco
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] Finer grained date output.
2005-08-20 2:17 ` Marco Matthies
2005-08-20 2:38 ` [gentoo-user] " Harry Putnam
@ 2005-08-20 5:08 ` Willie Wong
2005-08-20 11:45 ` Marco Matthies
1 sibling, 1 reply; 6+ messages in thread
From: Willie Wong @ 2005-08-20 5:08 UTC (permalink / raw
To: gentoo-user
On Sat, Aug 20, 2005 at 04:17:27AM +0200, Marco Matthies wrote:
> Harry Putnam wrote:
> >I know about perl scipting for this but wanted something like the
> >`date' command that is its own dedicated program.
> >
> >Is there a unix tool that outputs a finer grain of time segments?
>
> man date
> look for nanosecond format, e.g.:
> date +"%N"
The nanosecond option has always puzzled me, if only because on my box
I never get any finer grained output than microseconds... i.e. date
+%N always gives 0 as the last three digits.
Now technically this computer runs at 2 GHz... so presumably it is
possible to hit the enter key "not exactly on the microsecond". Is
there something in the kernel? or the clock?
W
--
You're not paranoid.
The world _IS_ fucked.
Sortir en Pantoufles: up 8 days, 8:08
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [gentoo-user] Finer grained date output.
2005-08-20 5:08 ` [gentoo-user] " Willie Wong
@ 2005-08-20 11:45 ` Marco Matthies
0 siblings, 0 replies; 6+ messages in thread
From: Marco Matthies @ 2005-08-20 11:45 UTC (permalink / raw
To: gentoo-user
Willie Wong wrote:
> The nanosecond option has always puzzled me, if only because on my box
> I never get any finer grained output than microseconds... i.e. date
> +%N always gives 0 as the last three digits.
>
> Now technically this computer runs at 2 GHz... so presumably it is
> possible to hit the enter key "not exactly on the microsecond". Is
> there something in the kernel? or the clock?
I'm also getting the last three digits zeroes.
I started digging a bit, this is what I found:
gettimeofday(2) says it returns microseconds
clock(3) apparently returns processor ticks, though naturally there will
be some hard limit to it's accuracy due to scheduling, etc.
The FreeBSD man page has some more about different clocks:
http://www.freebsd.org/cgi/man.cgi?query=clocks
Under Linux (couldn't find anything in fbsd) there is also
/sbin/hwclock, apparently an interface to the hardware clock. It seems
to take some while though to actually read it out.
So I don't know where date(1) is getting it's nanoseconds from, but I
suppose that nanoseconds is just there for upwards-compatibility and it
calls gettimeofday(2) at the moment.
Does anyone know some more details?
Marco
--
gentoo-user@gentoo.org mailing list
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-08-20 11:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-20 2:07 [gentoo-user] Finer grained date output Harry Putnam
2005-08-20 2:17 ` Marco Matthies
2005-08-20 2:38 ` [gentoo-user] " Harry Putnam
2005-08-20 2:58 ` Marco Matthies
2005-08-20 5:08 ` [gentoo-user] " Willie Wong
2005-08-20 11:45 ` Marco Matthies
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox