Synchronize Time in Linux

1

I want to synchronize the time between my android device and a raspberry pi. My android is synchronized automatically from the internet ( GMT + 2). I used this code to get the ntp server.

final Resources res = this.getResources();
        final int id = Resources.getSystem().getIdentifier(
                "config_ntpServer", "string","android");
        final String defaultServer = res.getString(id);
        Log.i("time",defaultServer);

Then I used this command to update the time on the raspberry working with the raspbian OS

sudo ntpdate -u 2.android.pool.ntp.org
24 Apr 17:07:06 ntpdate[20038]: adjust time server 77.20.139.240 offset 0.007060 sec

There is still 2 hours difference between the android and the linux. How can I set this GMT + 2 in linux ? Is such synchronization precise? I want to start advertising a beacon with the raspberry pi and measure the time it get to the android device to detect it so I will compare the two time stamps and the result will be in order of ms.

user3235881

Posted 2016-04-24T17:29:17.670

Reputation: 111

If there is still a 2 hour difference then they don't have the same NTP source or its a time zone setting difference. – Ramhound – 2016-04-24T17:39:06.620

Answers

0

It depends what linux distribution you're running, but I think Raspbian uses the same path as Debian and Ubuntu for timezone. You need to edit /etc/timezone to set your location, which should be one of the options listed in the tz database: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

Cody Jackson

Posted 2016-04-24T17:29:17.670

Reputation: 26