How to Fix NTP Error Linux sntp: adj_systime: Invalid argument
One of my clients AstLinux PBX’s was acting up a couple weeks ago by going into after hours mode in the middle of the day. Upon further investigation it turned out the PBX had lost power and rebooted so I realized the date/time was very wrong. The date command revealed the operating system believed it was 1999 so I figured the CR2032 battery on the board had gone bad. After replacing the battery I was expecting NTP to set the correct time for me, well that was a wrong assumption.
I restarted the NTP service many times only to continue getting an error of:
pbx ~ # service ntpd start Starting ntpd... sntp 4.2.8@1.3265-o Sat Feb 7 06:51:14 UTC 2015 (1) 2015-08-15 05:06:36.118274 (+0500) -8696498.478863 +/- 5797665.661695 north-america.pool.ntp.org 149.20.68.17 s2 adj_systime: Invalid argument
I checked the logs which reported the same issue:
pbx ~ # date Sat Jan 22 15:59:53 EST 2000 pbx ~ # cat /var/log/messages Jan 22 16:07:48 pbx daemon.notice ntpd[517]: ntpd 4.2.8@1.3265-o Sat Feb 7 06:49:37 UTC 2015 (1): Starting Jan 22 16:07:48 pbx daemon.info ntpd[517]: Command line: ntpd ? Jan 22 16:07:48 pbx daemon.info ntpd[518]: proto: precision = 11.734 usec (-16) Jan 22 16:07:48 pbx daemon.info ntpd[518]: getconfig: Couldn't open Jan 22 16:07:48 pbx daemon.info ntpd[518]: Listen and drop on 0 v4wildcard 0.0.0.0:123 Jan 22 16:07:48 pbx daemon.info ntpd[518]: Listen normally on 1 lo 127.0.0.1:123 Jan 22 16:07:48 pbx daemon.info ntpd[518]: Listen normally on 2 eth0 192.168.247.10:123 Jan 22 16:07:48 pbx daemon.info ntpd[518]: Listening on routing socket on fd #19 for interface updates Jan 22 16:09:03 pbx user.info sntp[700]: sntp 4.2.8@1.3265-o Sat Feb 7 06:51:14 UTC 2015 (1) Jan 22 16:09:03 pbx user.info sntp[700]: 2000-01-22 16:09:03.294382 (+0500) +482356762.551 +/- 321571175.034339 ntp.myfloridacity.us 71.40.128.146 s1 Jan 22 16:09:03 pbx user.err sntp[700]: adj_systime: Invalid argument
At this point I figured the date was so far off that the system could not calculate the correct time based on the Invalid argument log entry. So I went ahead and manually set the date/time using the date command.
pbx ~ # date -s 2015.05.17-13:28:00 Sun May 17 13:28:00 EDT 2015
Then I did a restart on the NTP service which restored NTP to working order.
pbx ~ # service ntpd restart
All was back to normal after that, just make sure to manually set the time to be as close as possible then restart the ntpd service.