[SOLVED] Time and timezone configuration

Started by bsrdjan, December 03, 2012, 03:27:49 AM

Previous topic - Next topic

bsrdjan

Hello,

I want to set the system time via NTP automatically after reboot.

Following those links
https://wiki.archlinux.org/index.php/Network_Time_Protocol_daemon
http://www.linuxsa.org.au/tips/time.html

I symlinked my timezone to /etc/localtime and installeed ntp.

I am able to set the correct time via NTP

ntpd -qg

However, after reboot, the /etc/localtime is not anymore symlinked to my local timezone and the time is again wrong.

How to fix that and is there a receipt how to configure Time Management properly on iMX233, eventually with RTC?

I see no response to this post either - any ideas how to configure Time for industrial applications would be really appreciated.
https://www.olimex.com/forum/index.php?topic=432.msg1636#msg1636

Thanks and regards,
srdjan

Christian Jann

You need to enable a NTP (Network Time Protocol) daemon at boot or attach a separate RTC clock.

Try the following commands:


pacman -Sy
pacman -S ntp
systemctl enable ntpd.service
systemctl start ntpd.service
date


Set the timezone in /etc/rc.conf:


TIMEZONE="America/Chicago"


Or execute the following command:


[root@alarm ~]# echo Europe/Berlin > /etc/timezone


Here are some usage examples:


[root@alarm ~]# pacman -Sy
:: Synchronizing package databases...
core                      38.3 KiB  89.5K/s 00:00 [######################] 100%
extra                    434.8 KiB  7.17K/s 01:01 [######################] 100%
community                438.6 KiB  7.35K/s 01:00 [######################] 100%
alarm                      4.9 KiB   166K/s 00:00 [######################] 100%
aur                       12.2 KiB  71.6K/s 00:00 [######################] 100%
[root@alarm ~]# pacman -S ntp
resolving dependencies...
looking for inter-conflicts...

Targets (1): ntp-4.2.6.p5-12

Total Download Size:    0.39 MiB
Total Installed Size:   1.49 MiB

Proceed with installation? [Y/n] y
:: Retrieving packages from extra...
ntp-4.2.6.p5-12-arm      395.2 KiB  7.90K/s 00:50 [######################] 100%
(1/1) checking package integrity                   [######################] 100%
(1/1) loading package files                        [######################] 100%
(1/1) checking for file conflicts                  [######################] 100%
(1/1) checking available disk space                [######################] 100%
(1/1) installing ntp                               [######################] 100%
[root@alarm ~]# systemctl enable ntpd.service
ln -s '/usr/lib/systemd/system/ntpd.service' '/etc/systemd/system/multi-user.target.wants/ntpd.service'
[root@alarm ~]# systemctl start ntpd.service
[root@alarm ~]# date
Thu Jan  1 01:02:45 CET 1970
[root@alarm ~]# date
Thu Jan  1 01:02:54 CET 1970
[root@alarm ~]# date
Thu Jan  1 01:03:14 CET 1970
[root@alarm ~]# date
Thu Jan  1 01:04:38 CET 1970
[root@alarm ~]# systemctl status ntpd.service
ntpd.service - Network Time Service
          Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled)
          Active: active (running) since Thu, 1970-01-01 01:00:13 CET; 4min 37s ago
        Process: 75 ExecStart=/usr/bin/ntpd -g -u ntp:ntp (code=exited, status=0/SUCCESS)
        Main PID: 98 (ntpd)
          CGroup: name=systemd:/system/ntpd.service
                    └─98 /usr/bin/ntpd -g -u ntp:ntp

Jan 01 01:00:19 alarm ntpd_intres[108]: host name not found: 0.pool.ntp.org
Jan 01 01:00:19 alarm ntpd_intres[108]: host name not found: 1.pool.ntp.org
Jan 01 01:00:19 alarm ntpd_intres[108]: host name not found: 2.pool.ntp.org
Jan 01 01:01:21 alarm ntpd_intres[108]: host name not found: 0.pool.ntp.org
Jan 01 01:01:21 alarm ntpd_intres[108]: host name not found: 1.pool.ntp.org
Jan 01 01:01:21 alarm ntpd_intres[108]: host name not found: 2.pool.ntp.org
Jan 01 01:02:02 alarm ntpd[98]: Listen normally on 2 wlan0 10.42.0.48 UDP 123
Jan 01 01:02:02 alarm ntpd[98]: peers refreshed
Jan 01 01:02:02 alarm ntpd[98]: new interface(s) found: waking up resolver
Jan 01 01:02:37 alarm systemd[1]: Started Network Time Service.
[root@alarm ~]# ping google.de
PING google.de (74.125.230.216) 56(84) bytes of data.
64 bytes from par08s09-in-f24.1e100.net (74.125.230.216): icmp_seq=1 ttl=52 time=60.6 ms
64 bytes from par08s09-in-f24.1e100.net (74.125.230.216): icmp_seq=2 ttl=52 time=78.4 ms

--- google.de ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 60.656/69.531/78.406/8.875 ms
[root@alarm ~]# systemctl start ntpd.service
[root@alarm ~]# systemctl status ntpd.service
ntpd.service - Network Time Service
          Loaded: loaded (/usr/lib/systemd/system/ntpd.service; enabled)
          Active: active (running) since Thu, 1970-01-01 01:00:13 CET; 42 years and 11 months ago
        Process: 75 ExecStart=/usr/bin/ntpd -g -u ntp:ntp (code=exited, status=0/SUCCESS)
        Main PID: 98 (ntpd)
          CGroup: name=systemd:/system/ntpd.service
                    └─98 /usr/bin/ntpd -g -u ntp:ntp

Jan 01 01:00:19 alarm ntpd_intres[108]: host name not found: 1.pool.ntp.org
Jan 01 01:00:19 alarm ntpd_intres[108]: host name not found: 2.pool.ntp.org
Jan 01 01:01:21 alarm ntpd_intres[108]: host name not found: 0.pool.ntp.org
Jan 01 01:01:21 alarm ntpd_intres[108]: host name not found: 1.pool.ntp.org
Jan 01 01:01:21 alarm ntpd_intres[108]: host name not found: 2.pool.ntp.org
Jan 01 01:02:02 alarm ntpd[98]: Listen normally on 2 wlan0 10.42.0.48 UDP 123
Jan 01 01:02:02 alarm ntpd[98]: peers refreshed
Jan 01 01:02:02 alarm ntpd[98]: new interface(s) found: waking up resolver
Jan 01 01:02:37 alarm systemd[1]: Started Network Time Service.
Jan 01 01:05:21 alarm systemd[1]: Started Network Time Service.
[root@alarm ~]# date
Tue Dec 18 16:06:09 CET 2012
[root@alarm ~]#


The following two blog posts may be helpful to you:

http://www.jann.cc/2012/08/23/building_a_kernel_3_x_for_the_olinuxino_from_sources.html
http://www.jann.cc/2012/12/16/using_the_olinuxino_micro_and_a_usb_3g_modem_to_control_something_via_web.html