Time did not update

I have Freepbx running as a hyper-v vm. I was doing some updates to the Hyper-v server the other day and I just saved the state of all the VMs while doing this.

I have some time conditions in my setup and a few days later I realized the time on the FreePBX vm was off by about the same amount of time the vm had stayed in the “saved” state (about 1.5 hours). I was in a rush so did not check to see if the ntpd service was running or anything, and just rebooted in case there were other problems it was facing.

My Questions is how often does FreePBX (centOS) resync itself to time servers? Would have thought that after a few days it would have resynced itself. Can I change the intervals?

ntpd will not do huge jumps - it adjusts a little bit at a time.

The way I’d have fixed it is:

Stop ntpd.
Run ntpdate -B ntp.server.of.your.choice
Start ntpd.

It’s been a couple years since I’ve had to do it, but if you get an error from ntpdate that the skew is too large, try “-b” instead of “-B”.

1 Like

Anything I can do to have larger time gaps fixed automatically if they happen again in the future? I’d almost like to have a nightly reboot for unexpected instances and issues such as this one. I know it’s not a standard thing but since reboots fix 99% of problems maybe it would not be too bad to do.

It’s a three line script in a cron job. You shouldn’t need to reboot every (or any) night. Just configure ntp and run the “jumper” code from time to time. If you rely on ntp full time, you shouldn’t ever need it (since it adjust at random intervals throughout the day.

1 Like

So you’re saying to create a cron job to do a full time sync once a day?

Sure. It’s a little belt-and-suspenders but it’s only once a day at midnight, It won’t hurt anything.

is the host losing time too?

NO the host is fine. But the Host was not in a saved state…

Would you happen to know the commands to implement the cron job? sorry, I’m not familiar with it. I can look it up if it’s complicated.

these commands:

service ntpd stop; service ntpdate start; service ntpd start;

will stop ntpd, use ntpdate to refresh the time and then start ntpd backup again.

For testing… I did
date -s "2006-08-07 12:34:56-06:00"
and set my clock back a ways… then I ran:
service ntpd stop; service ntpdate start; service ntpd start;
and corrected the time.

not sure if
0 23 * * * service ntpd stop; service ntpdate start; service ntpd start;
will work from cron or not… might want to put those commands in a /usr/local/sbin/sync_clock script and call that from cron… but those commands might get you started.

jack

1 Like

Thanks a million Jack/James/dave. Really appreciate all your help.

Will give it a go!

@jfinstrom has a good point. To my way of thinking, Asterisk should skew to the correct time once in a while too.

All the ntpdate command will do is change the host time. If that’s not the issue, the problem is somewhere else.

@colin911 - you might want to put in a trouble ticket (Issues, above) describing what you saw. There might be a time-hack missing when the system comes out of the saved state? If it’s nothing, everyone is fine, if it’s a problem, I’d think it might need to be fixed.

@dave, I’ll list it. thanks.