Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mark2288

macrumors regular
Original poster
Jan 11, 2006
239
4
Hey all,
I am trying to use the date command in Terminal on multiple machines that are synced via NTP to synchronize some code in a program. Essentially I am running a program...

MyProgram with arguments:date

I can get date to give me the seconds since the Unix epoch with the %M specifier.

http://en.wikipedia.org/wiki/Date_(Unix)

When I try to use %N to get nanosecond resolution, date just returns N. Is there anyway to get date to give me finer then second resolution? I wouldn't even mind passing two arguments such as

(date +%M):arg2

And then converting units in the program.

Many thanks in advance!
 
the date command on OS X does not appear to be able to give you anything finer than resolution of seconds.


but beyond that, you are probably only synced at the millisecond level with NTP, and calling another program on the terminal to give you a high resolution clock erases all the accuracy that you're seeking.

you can get millisecond resolution with the gettimeofday() function in <sys/time.h>


-j

Hey all,
I am trying to use the date command in Terminal on multiple machines that are synced via NTP to synchronize some code in a program. Essentially I am running a program...

MyProgram with arguments:date

I can get date to give me the seconds since the Unix epoch with the %M specifier.

http://en.wikipedia.org/wiki/Date_(Unix)

When I try to use %N to get nanosecond resolution, date just returns N. Is there anyway to get date to give me finer then second resolution? I wouldn't even mind passing two arguments such as

(date +%M):arg2

And then converting units in the program.

Many thanks in advance!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.