[ntp:questions] Re: NTP sync status
kostecke at ntp.isc.org
Thu Jun 23 21:18:17 UTC 2005
On 2005-06-23, Eugene.Novak at gmail.com <Eugene.Novak at gmail.com> wrote:
> I want to write a bash script which checks to see the status of NTP. I
> need to know whether it is sync'ing with the external server or not.
> Is there a command line method that returns something like a 0 or 1
> based on if NTP is sync'ing with an external server? Thanks.
This sets the return variable for use in a conditional:
ntpq -p | grep -q "^\*"
This makes it human readable:
ntpq -p | grep -q "^\*"; echo $?
Steve Kostecke <kostecke at ntp.isc.org>
NTP Public Services Project - http://ntp.isc.org/
More information about the questions