[ntp:questions] ntp? return value for use in scripts

David Wuertele dave-gnus at bfnet.com
Mon Jan 26 22:19:26 UTC 2004


I want to write a script that does the following:

  /sbin/ntpsomecommand
  if [ $? -eq 0 ]
  then
    # sys time is apparently synchronized; so use it to set the 
    # non-volatile clock
    /sbin/hwclock --systohc
  else
    # sys time is NOT synchronized (maybe the network is down), so
    # use the non-volatile clock to set the sys time
    /sbin/hwclock --hctosys
  fi

Is there a command I can run that returns an explicit value based on
whether my system time is being sync'd to Internet NTP services?

Thanks,
Dave



More information about the questions mailing list