Home Man
Today's Posts

HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V.

Script to detect time drift

drift, hp-ux, ntp

Login to Reply

Thread Tools Search this Thread
# 8  
Old 05-14-2018
Thanks a lot for your response MadeInGermany.

I will try this.

# 9  
Old 05-14-2018
The following is even simpler, because sed simply strips a leading - and a trailing .xxx.
This would even run in bash or dash.
ntpq -c rl | sed -n '
if [[ -z $offset ]]
  echo "no offset, check NTP service with ntpq -pn"
elif [[ $offset -gt 50 ]]
  echo "$offset is greater than 50 msec"

Last edited by MadeInGermany; 05-16-2018 at 02:29 PM.. Reason: added check for empty return value
# 10  
Old 05-16-2018
Hi MadeInGermany,

Quick question for my knowledge purposes.
If NTP is scheduled to run every 10 minutes on the server, do you think the clocks get synchronised?
Will there be an explicit need to check for the time drifts? Can the time drift situation occur at all?

Thank you.
# 11  
Old 05-16-2018
This ntpq is a measurement.
If you trust your NTP setup then you do not need a measurement.

BTW I just have changed my last post, added another check for the case that NTP service does not work (somebody stopped it, all time peers are unreachable, ...).

With HP-UX 11.23 I remember a strangeness: ntpq reported sudden time jumps and the monitoring got occasional alerts.
No such issues on AIX, Solaris, Linux.

driftfile is not relevant. This is the drift between the hardware clock and the NTP servers., that predicts the real drift in case the time peers would not be reachable. Effectively it only causes a faster time sync after a startup of the NTP service. One can run NTP without a driftfile.

Last edited by MadeInGermany; 05-16-2018 at 02:39 PM..
The Following User Says Thank You to MadeInGermany For This Useful Post:
Green_Star (05-17-2018)
# 12  
Old 05-17-2018

Thanks a lot for sharing your knowledge - MadeInGermany.
# 13  
Old 05-23-2018

One more question.
Once we detect the offset >+/- 50ms, can we correct the time within the script i.e. get the time in sync ?


Last edited by Green_Star; 05-23-2018 at 11:36 AM..
# 14  
Old 05-23-2018
No, this is monitoring. Once monitoring detects an offset you must do a root cause analysis why your sync mechanism has failed.
Your sync mechanism:
ensure there is either ntpd running (needs a correctly configured ntp.conf, check with ntpq -pn) or a cron job with ntpdate.
The Following User Says Thank You to MadeInGermany For This Useful Post:
Green_Star (05-23-2018)
Login to Reply

« Previous Thread | Next Thread »
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script to detect time drift on server Green_Star UNIX for Beginners Questions & Answers 1 05-10-2018 03:13 PM
A script to detect system type dampio UNIX for Advanced & Expert Users 1 01-24-2018 05:02 AM
Help with detect with regex and move script Simplify Shell Programming and Scripting 7 01-19-2017 09:58 AM
Bash script to detect nonpingable hosts newbie2010 Shell Programming and Scripting 5 06-02-2013 05:17 PM
How to detect key press in cgi shell script? Shuinvy Shell Programming and Scripting 2 12-07-2012 04:06 AM
Detect if script starts from queue Lord Spectre Shell Programming and Scripting 16 08-16-2012 11:09 AM
AWK script to detect webpages from file ROFL Shell Programming and Scripting 2 03-23-2010 08:22 AM
AWK script to detect webpages from file ROFL Shell Programming and Scripting 1 03-22-2010 12:22 PM
how to detect my script is already running rmulchandani UNIX for Dummies Questions & Answers 11 01-26-2009 05:10 PM

All times are GMT -4. The time now is 12:59 AM.

Unix & Linux Forums Content Copyrightę1993-2018. All Rights Reserved.
Show Password