Network Time Protocol (NTP)

Post here if you are a new Porteus member and you're looking for some help.
User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Network Time Protocol (NTP)

Post#1 by Ed_P » 14 Mar 2017, 14:32

Evan wrote:So it doesn't get lost in random chat.
Thank you Evan. :good:

Do note, those commands need to be run as root.

-update-

A related thread: Porteus clock. How it works.

And the two commands you posted do indeed finally resolve the multi-boot problem with Windows and the machine clock set as local time. :Yahoo!:
Ed

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Network Time Protocol (NTP)

Post#2 by Ed_P » 16 Dec 2019, 21:43

Ok, this is an old thread but I think it relates to my new question.

Code: Select all

guest@porteus:~$ su
Password: 
root@porteus:/home/guest# hwclock
2019-12-16 11:17:35.432779-05:00
root@porteus:/home/guest# ntpdate pool.ntp.org
16 Dec     16:18:19 ntpdate[1812]: adjust time server 96.245.170.99 offset 0.009361 sec
root@porteus:/home/guest# uname -a
Linux porteus 4.16.3-porteus #1 SMP PREEMPT Sat Apr 21 12:42:52 Local time zone must be set-- x86_64 Intel(R) Core(TM) i3-6100U CPU @ 2.30GHz GenuineIntel GNU/Linux
root@porteus:/home/guest# rm /etc/localtime
root@porteus:/home/guest# ln -s /usr/share/zoneinfo/US/Eastern   /etc/localtime
root@porteus:/home/guest# hwclock
2019-12-16 11:20:29.074001-05:00
root@porteus:/home/guest# ntpdate pool.ntp.org
16 Dec     16:21:00 ntpdate[1820]: adjust time server 69.164.213.136 offset -0.006076 sec
root@porteus:/home/guest# uname -a
Linux porteus 4.16.3-porteus #1 SMP PREEMPT Sat Apr 21 12:42:52 Local time zone must be set-- x86_64 Intel(R) Core(TM) i3-6100U CPU @ 2.30GHz GenuineIntel GNU/Linux
root@porteus:/home/guest# 
How does one get the uname -a msg to not report the local time zone must be set? The time in Porteus, and Windows, on the machine are displaying the current time.

The Date & Time Settings Window in Porteus displays the Region as Europe, London though I am in the Eastern Time zone. In the past attempting to change the display to Eastern resulted in the machine's clock being reset which messed up the clock in Windows.
Ed

jssouza
Legendary
Legendary
Posts: 1165
Joined: 09 Jul 2015, 14:17
Distribution: Porteus x86 arm

Network Time Protocol (NTP)

Post#3 by jssouza » 17 Dec 2019, 04:24

Ed_P wrote:
16 Dec 2019, 21:43
How does one get the uname -a msg to not report the local time zone must be set?
Oh that's simple. You need to recompile the kernel with your timezone set ;)
Ed_P wrote:
16 Dec 2019, 21:43
The Date & Time Settings Window in Porteus displays the Region as Europe, London
This could be because London is GMT (during winter) which is basically UTC. But this is a guess.

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Network Time Protocol (NTP)

Post#4 by Ed_P » 17 Dec 2019, 19:23

Recompile the kernel!! Really?? Wow! Thanks jssouza. :)
Ed

jssouza
Legendary
Legendary
Posts: 1165
Joined: 09 Jul 2015, 14:17
Distribution: Porteus x86 arm

Network Time Protocol (NTP)

Post#5 by jssouza » 18 Dec 2019, 01:19

Ed_P wrote:
17 Dec 2019, 19:23
Recompile the kernel!! Really??
Yes. As you know now, uname -a shows the date and time at which the kernel was built. And just like 6:45 in the morning for me is not the same time for you, the time part of the uname -a has to be suffixed with a timezone, which will not work if the machine that compiled the kernel did not have the timezone set.

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Network Time Protocol (NTP)

Post#6 by Ed_P » 18 Dec 2019, 04:47

If I recompile a kernel (a very unlikely thing I could do) with the machine's clock set to a different time how does the new kernel know what, and if, time zone has been set?
Ed

jssouza
Legendary
Legendary
Posts: 1165
Joined: 09 Jul 2015, 14:17
Distribution: Porteus x86 arm

Network Time Protocol (NTP)

Post#7 by jssouza » 18 Dec 2019, 06:17

Ed_P wrote:
18 Dec 2019, 04:47
If I recompile a kernel (a very unlikely thing I could do) with the machine's clock set to a different time how does the new kernel know what, and if, time zone has been set?
Interesting question, I traced it this way:
uname uses the utsname structure and in particular the version entry to get the version with the timestamp (See here and the other entries: http://man7.org/linux/man-pages/man2/uname.2.html)
So the linux kernel has to have a similar entry with it that it populates.
Searching kernel sources it does so in the init.c (https://git.kernel.org/pub/scm/linux/ke ... h=v5.5-rc2) to UTS_VERSION.
Checking where UTS_VERSION is populated:
In scripts/mkcompile_h (https://git.kernel.org/pub/scm/linux/ke ... h=v5.5-rc2)

Code: Select all

UTS_VERSION="$UTS_VERSION $CONFIG_FLAGS $TIMESTAMP"
And in the same file, $TIMESTAMP is initialized to:

Code: Select all

TIMESTAMP=`date`
So there you have it: During compilation, the compile script runs the date command of the system where it is compiled and populates it in the kernel. If the timezone is not set, I guess the date command will have the "Local time zone must be set" also, which gets into the kernel and which the uname command subsequently also retrieves.

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Network Time Protocol (NTP)

Post#8 by Ed_P » 18 Dec 2019, 06:33

Interesting. Date does show the time zone.

Code: Select all

guest@porteus:~$ date
Wed Dec 18 01:31:19 EST 2019
guest@porteus:~$ 
Ed

jssouza
Legendary
Legendary
Posts: 1165
Joined: 09 Jul 2015, 14:17
Distribution: Porteus x86 arm

Network Time Protocol (NTP)

Post#9 by jssouza » 18 Dec 2019, 06:39

Not if you havent set timezone, it doesnt.

Code: Select all

[guest:~]$ date
Wed Dec 18 12:08:45 Local time zone must be set--see zic manual page 2019
[guest:~]$ cat /etc/localtime
TZif21Local time zone must be set--see zic manual pageTZif21Local time zone must be set--see zic manual page
<Local time zone must be set--see zic manual page>0

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Network Time Protocol (NTP)

Post#10 by Ed_P » 18 Dec 2019, 07:02

hmmm So this is how Eastern looks!! :shock:

Code: Select all

guest@porteus:~$ date
Wed Dec 18 01:31:19 EST 2019
guest@porteus:~$ cat /etc/localtime
TZif2����p���`��p���`�e�p�����j�p�5�`�S����`�3����������އ���p���i���R���K௳4��~-౜Qp�gJ`�|3p�G,`�\p�'`�;�p��`��p���`����ƴ`���������Ĺ𿏲������o��
                                                                     }��Ov��d_��@p��9`ˈ�p�#�p�`���u���@���U��� ���5���������������p��e��މpݩ�`޾kp߉d`��Mp�iF`�~/p�I(`�^p�W.��G-��7��'����������������ֶ��Ƶ����`���p���`���p��`�o�p�_y`�Oxp�?[`�/Zp�(w��<pY���X���;���:�����������������w��p�``�pP�`@�p0�`�p	�`	���
��`
   ��p
�gp�������f��e�yH�iG�Y*�I)�9
                                   �)
                                      �")`��
                                               `�
p��`��p��`��p��` v�!��`"U��#j��$5��%J��&��'*s�'��p)
A�I�l�J�#�K��pL�@`M|kpN�"`O\MpP�`Q</pRu�`SpTU�`T��pV5�`V��X��X���Y���Z���[ފ�xpeG/`e�Zpg'`g�<pi�`i�pj��`k�:�l���mv�n���oU��p���q5��ro��s��tOy�t��pv8�`v��pxx`x��py�Z`z��p{�<`|~gp}�`~^Ip�`���������������
                                                  ����LMTEDTESTEWTEPTTZif2������^��������p�������`������p�������`�����e�p�������������j�p�����5�`�����S��������`�����3����������������������އ�������p�������i�������R�������K�������4������~-�������Qp�����gJ`�����|3p�����G,`�����\p�����'`�����;�p������`������p�������`������������ƴ`���������������������Ĺ����������������������o������
                                                                        }������O@p������9`����ˈ�p�����#�p�����`�������u�������@�������U������� �������5�������������������������������p������e������މp����ݩ�`����޾kp����߉d`������Mp�����iF`�����~/p�����I(`�����^p�����W.������G-������7������'������������������������������������ֶ������Ƶ��������`�������p�������`�������p������`�����o�p�����_y`�����Oxp�����?[`�����/Zp�����(w������<p����Y�������X�������;�������:�����������������������������w��p�``�pP�`@�p0�`�p	�`	���
��`
   ��p
�gp�������f��e�yH�iG�Y*�I)�9
                                   �)
                                      �")`��
                                               `�
p��`��p��`��p��` v�!��`"U��#j��$5��%J��&��'*s�'��p)
A�I�l�J�#�K��pL�@`M|kpN�"`O\MpP�`Q</pRu�`SpTU�`T��pV5�`V��X��X���Y���Z���[ފ�xpeG/`e�Zpg'`g�<pi�`i�pj��`k�:�l���mv�n���oU��p���q5��ro��s��tOy�t��pv8�`v��pxx`x��py�Z`z��p{�<`|~gp}�`~^Ip�`���������������
                                                  ����LMTEDTESTEWTEPT
EST5EDT,M3.2.0,M11.1.0
guest@porteus:~$ 
Ed

jssouza
Legendary
Legendary
Posts: 1165
Joined: 09 Jul 2015, 14:17
Distribution: Porteus x86 arm

Network Time Protocol (NTP)

Post#11 by jssouza » 18 Dec 2019, 07:06

:D

Run this:
[guest:~]$ file /etc/localtime

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Network Time Protocol (NTP)

Post#12 by Ed_P » 18 Dec 2019, 15:12

hmmm a slightly better perspective. :happy62:

Code: Select all

guest@porteus:~$ file /etc/localtime
/etc/localtime: symbolic link to /usr/share/zoneinfo/US/Eastern
:good:
Ed

jssouza
Legendary
Legendary
Posts: 1165
Joined: 09 Jul 2015, 14:17
Distribution: Porteus x86 arm

Network Time Protocol (NTP)

Post#13 by jssouza » 18 Dec 2019, 15:59

Well done. Now run the same file command on /usr/share/zoneinfo/US/Eastern and you can see why /etc/localtime looked the way to you and how setting timezone works :happy62:

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Network Time Protocol (NTP)

Post#14 by Ed_P » 18 Dec 2019, 16:32

Interesting. But I don't know, the cat command seems more inclusive.

Code: Select all

guest@porteus:~$ file /usr/share/zoneinfo/US/Eastern
/usr/share/zoneinfo/US/Eastern: timezone data, version 2, 5 gmt time flags, 5 std time flags, no leap seconds, 236 transition times, 5 abbreviation chars

guest@porteus:~$ cat /usr/share/zoneinfo/US/Eastern
TZif2����p���`��p���`�e�p�����j�p�5�`�S����`�3����������އ���p���i���R���K௳4��~-౜Qp�gJ`�|3p�G,`�\p�'`�;�p��`��p���`����ƴ`���������Ĺ𿏲������o��
                                                                     }��Ov��d_��@p��9`ˈ�p�#�p�`���u���@���U��� ���5���������������p��e��މpݩ�`޾kp߉d`��Mp�iF`�~/p�I(`�^p�W.��G-��7��'����������������ֶ��Ƶ����`���p���`���p��`�o�p�_y`�Oxp�?[`�/Zp�(w��<pY���X���;���:�����������������w��p�``�pP�`@�p0�`�p	�`	���
��`
   ��p
�gp�������f��e�yH�iG�Y*�I)�9
                                   �)
                                      �")`��
                                               `�
p��`��p��`��p��` v�!��`"U��#j��$5��%J��&��'*s�'��p)
A�I�l�J�#�K��pL�@`M|kpN�"`O\MpP�`Q</pRu�`SpTU�`T��pV5�`V��X��X���Y���Z���[ފ�xpeG/`e�Zpg'`g�<pi�`i�pj��`k�:�l���mv�n���oU��p���q5��ro��s��tOy�t��pv8�`v��pxx`x��py�Z`z��p{�<`|~gp}�`~^Ip�`���������������
                                                  ����LMTEDTESTEWTEPTTZif2������^��������p�������`������p�������`�����e�p�������������j�p�����5�`�����S��������`�����3����������������������އ�������p�������i�������R�������K�������4������~-�������Qp�����gJ`�����|3p�����G,`�����\p�����'`�����;�p������`������p�������`������������ƴ`���������������������Ĺ����������������������o������
                                                                        }������O@p������9`����ˈ�p�����#�p�����`�������u�������@�������U������� �������5�������������������������������p������e������މp����ݩ�`����޾kp����߉d`������Mp�����iF`�����~/p�����I(`�����^p�����W.������G-������7������'������������������������������������ֶ������Ƶ��������`�������p�������`�������p������`�����o�p�����_y`�����Oxp�����?[`�����/Zp�����(w������<p����Y�������X�������;�������:�����������������������������w��p�``�pP�`@�p0�`�p	�`	���
��`
   ��p
�gp�������f��e�yH�iG�Y*�I)�9
                                   �)
                                      �")`��
                                               `�
p��`��p��`��p��` v�!��`"U��#j��$5��%J��&��'*s�'��p)
A�I�l�J�#�K��pL�@`M|kpN�"`O\MpP�`Q</pRu�`SpTU�`T��pV5�`V��X��X���Y���Z���[ފ�xpeG/`e�Zpg'`g�<pi�`i�pj��`k�:�l���mv�n���oU��p���q5��ro��s��tOy�t��pv8�`v��pxx`x��py�Z`z��p{�<`|~gp}�`~^Ip�`���������������
                                                  ����LMTEDTESTEWTEPT
EST5EDT,M3.2.0,M11.1.0
guest@porteus:~$ 
:D

Need a command that displays hex code into readable characters.

BTW I'd never used the file command before. Thanks for pointing it out. :beer:
Ed

Post Reply