Page 1 of 1

Network Time Protocol (NTP)

Posted: 14 Mar 2017, 14:32
by Ed_P
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!:

Network Time Protocol (NTP)

Posted: 16 Dec 2019, 21:43
by Ed_P
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.

Network Time Protocol (NTP)

Posted: 17 Dec 2019, 04:24
by jssouza
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.

Network Time Protocol (NTP)

Posted: 17 Dec 2019, 19:23
by Ed_P
Recompile the kernel!! Really?? Wow! Thanks jssouza. :)

Network Time Protocol (NTP)

Posted: 18 Dec 2019, 01:19
by jssouza
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.

Network Time Protocol (NTP)

Posted: 18 Dec 2019, 04:47
by Ed_P
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?

Network Time Protocol (NTP)

Posted: 18 Dec 2019, 06:17
by jssouza
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.

Network Time Protocol (NTP)

Posted: 18 Dec 2019, 06:33
by Ed_P
Interesting. Date does show the time zone.

Code: Select all

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

Network Time Protocol (NTP)

Posted: 18 Dec 2019, 06:39
by jssouza
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

Network Time Protocol (NTP)

Posted: 18 Dec 2019, 07:02
by Ed_P
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:~$ 

Network Time Protocol (NTP)

Posted: 18 Dec 2019, 07:06
by jssouza
:D

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

Network Time Protocol (NTP)

Posted: 18 Dec 2019, 15:12
by Ed_P
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:

Network Time Protocol (NTP)

Posted: 18 Dec 2019, 15:59
by jssouza
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:

Network Time Protocol (NTP)

Posted: 18 Dec 2019, 16:32
by Ed_P
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: