How to change NTP server


#1

Hi,
I wanted to change NTC server, so I opened file /etc/time_service.conf
(original content)

#TIME_SERVICES="qcom_time ntpd_time"
TIME_SERVICES="qcom_time"
NTPD_SERVERS="pool.ntp.org"
NTPD_USE_DNS_SERVERS="n"
NTPD_USE_GATEWAY="n"
NTPD_ONESHOT=“y”

I changed line from NTPD_SERVERS=“pool.ntp.org” to NTPD_SERVERS=“bleble”. I am sure, NTP server ‘blabla’ does not exist, so why time has been synchronised?
When i disable line TIME_SERVICES=“qcom_time”, time is not sychronised. This is correct.
Where can I change NTP server? NTPD_SERVERS in /etc/time_service.conf does not take effect in my opinion.
Whats a difference between TIME_SERVICES=“qcom_time ntpd_time” and TIME_SERVICES=“qcom_time”?
Where can I change time zone?

Thanks


Get time to sync on boot on MangOH Green
#2

Time base is explained here:
http://legato.io/legato-docs/latest/howToSetUserTimebase.html

The time update is by default coming from cellular network time, you can follow this link to disable it:
http://legato.io/legato-docs/latest/c_rtc.html#c_rtc_disableDaemon

Hope it helps.
Thx


#3

Hi,
Thanks for reply.
First link:Time base is explained but it does say how to change NTP.
Second link explains how to turn off time synch (NTP), but again, it does say how to change NTP server. I need to synch time, but I have to synch with specific server


#4

If you understand the explanation, we should at least modify as below, please try and fine tune if you need to modify the remaining USE_DNS or USE_GATEWAY or ONESHOT setting.

#TIME_SERVICES="qcom_time ntpd_time"
TIME_SERVICES="ntpd_time"
NTPD_SERVERS="bleble"
NTPD_USE_DNS_SERVERS="n"
NTPD_USE_GATEWAY="n"
NTPD_ONESHOT=“y”


#5

When I change to TIME_SERVICES=“ntpd_time” it does not work at all (even if NTP server is correct). I have tried with all combinations USE_DNS, USE_GATEWAY and ONESHOT.

#TIME_SERVICES="qcom_time ntpd_time"
TIME_SERVICES="ntpd_time"
NTPD_SERVERS="pool.ntp.org"
NTPD_USE_DNS_SERVERS="n"
NTPD_USE_GATEWAY="n"
NTPD_ONESHOT=“y”

It always work when TIME_SERVICES=“qcom_time ntpd_time” or TIME_SERVICES=“qcom_time” (other NTPD_* lines are ignored I think). If I modify TIME_SERVICES it never works, no matter what i put in NTPD_SERVERS, USE_DNS, USE_GATEWAY, ONESHOT.


#6

Update
TIME_SERVICES=“ntpd_time” works only if I connect to internet via eth cable.

#TIME_SERVICES="qcom_time ntpd_time"
TIME_SERVICES="ntpd_time"
NTPD_SERVERS="80.153.195.191"
NTPD_USE_DNS_SERVERS="n"
NTPD_USE_GATEWAY="n"
NTPD_ONESHOT=“n”

I have noticed, date and time is synch without internet connection when TIME_SERVICES=“qcom_time” is set. Does anyone know how FX30 synchronize time without access to NTP (sim is in and is logged to GSM network but without connection to internet)? How does it work?


#7

As mentioned in the link, “qcom_time” make use the cellular network time (NITZ) so it will work and automatic update the system time if the registered carrier network support it.

For NTP issue, to my understanding, it will fail and terminate if no IP connectivity when the script run.
So maybe your app can force run this script after it setup data connection properly, or trigger command “/usr/sbin/ntpd -p 80.153.195.191” whenever you want to sync the time.

Hope it helps.


#8

hi
I have the same problem now.
How did you solve it?


Unable to run NTP
#9

Hi,
I took @lotam advice and sync time manually after data connection is established.
In other words. If you want to sync date and time you have to run

system("/usr/sbin/ntpd -p <your ntp server here>");

in your code.


#10

Hi,
I tried using this command to run ntp but still its not working.
I tried running sudo dpkg install ntp command , but it is showing dkpg not installed
Please guide on how to install dpkg

Thanks


#11

Hi @Sahithi,
Do you run this command system("/usr/sbin/ntpd -p <your ntp server here>"); from terminal or use it in your code?


#12

We used it in the code.

Here is a screenshot of the code.

It still shows the error ‘host name not found’. (The same code works when run on a linux machine.)


#13

Hi,
To synch the time you have to establish internet connection (make sure you are connected) and run system("/usr/sbin/ntpd -p <your ntp server here>");. End of story.

I have got no idea why you want to resolve us.pool.ntp.org, open socket, … etc. If you want to open the socket anyway try 0.us.pool.ntp.org, 1.us.pool.ntp.org, 2.us.pool.ntp.org or 3.us.pool.ntp.org instead of us.pool.ntp.org

Or check iptables