34

I want to know the time on a server accurate to the millisecond.

there's this way:

local $ ssh user@servername
Welcome to server!
server $ date
Fri Feb 18 11:27:50 EST 2011

But I need more accuracy. Is there a command that will be more precise?

fixer1234
  • 27,064
  • 61
  • 75
  • 116
user2254
  • 653
  • 3
  • 7
  • 10

2 Answers2

42

Check " man date ". You can let it display you the hours, minutes, seconds and nanoseconds with

date +%H:%M:%S.%N

See the output of

while : ; do date +%H:%M:%S.%N ; done

interrupt the infinite while loop with CTRL+C .

If you want less decimal places you could do

while : ; do date +%H:%M:%S.%N | cut -c 1-12 ; done

Increase or decrease the output length changing the "12" on "-c 1-12" after cut.

rems
  • 2,008
  • 1
  • 17
  • 9
0

No commands that I am aware of, but you can call gettimeofday to get results accurate to the millisecond. There are compilable examples on StackOverflow, CTT's in particular would be of interest.

John T
  • 163,373
  • 27
  • 341
  • 348