Embedded Linux busybox NTP time synchronization __linux

Source: Internet
Author: User
Tags time zones local time
turn from: http://hi.baidu.com/uc100200/blog/item/cccef6b517b512de37d3ca02.html a , BackgroundThe machine is loaded with BusyBox, using the smallest set of Linux. The hardware clock is local time, the kernel clock is UTC time, no time zone is set, and there is no option for any time zone setting. Second, demandThis machine needs to be timed for NTP time synchronization. local time is displayed to the user after synchronization. third, the process 1. Time zone Support (1) Hwclock to see if the hardware clock is local time, run the command hwclock–r. The result system prompts: "Could not open rtc:no such file or directory", that is, the RTC file cannot be found. (2)/DEV/RTC          because the kernel does not provide RTC support during the compilation process, the kernel needs to be recompiled (or added a module for the kernel). method, in the Make menuconfig phase, the support for "enhanced real time Clock Support" of "Character Device" is selected. When the module is added to the kernel, the RTC file appears under the directory/proc/drive/, and cat can also see the normal content. However, there is still no RTC file in the/dev/directory. The RTC file is then added to the/dev directory via the Mknod command. By the man RTC, the RTC is a read-only character device, master 10, from 135. So the command is "MKNOD/DEV/RTC C 10 135". The RTC file was successfully generated under/dev after the command was executed. Run Hwclock–r to see the hardware time as local time. The date command is used to view the system time, but UTC time. This indicates that the system does not have a local time setting. (3)/etc/localtime         Linux system time zones are obtained by means of symbolic connection/etc/localtime. You can set the time zone by using the Tzset command. Without this command, you can set the time zone to Shanghai in Asia by using the command "Ln–s/etc/localtime/usr/share/zoneinfo/asia/shanghai". Because the system was originally built without zoneinfo information, the Zoneinfo directory and its files do not exist in the/usr/share directory. So the entire Zoneinfo directory in the/usr/share directory of the machine containing the Zoneinfo information is copied to the/usr/share directory of this machine. Check the time with the date command and find that it has become a normal local time: MonAug 13:14:29 CST (4)/etc/sysconfig/clock         This profile can be used to set how the user chooses to display the time. If the hardware clock is local time, UTC is set to 0 and no environment variable TZ is set. If the hardware clock is UTC time, set UTC to 1 and set the environment variable TZ (or configuration file/etc/tz) as time zone information, such as "Asia/shanghai". The hardware time of my machine is local time, so the configuration file is: zone= "Asia/shanghai" utc=0 arc=0 2. NTP synchronization settings (1) ntpdate If you are only synchronizing system time through an NTP server, you can use command Ntpdate (located under/usr/sbin/, which provides better overall functionality with NTPD). The libraries used by Ntpdate include: Libcap.so.1 =>/lib/libcap.so.1, libc.so.6 =>/lib/tls/libc.so.6,         /lib/ld-linux.so.2 (0xf6fdf000). Copy the command file and related libraries to this machine and find a recent stable NTP server. I'm using nets.org.sg (ip:203.117.180.36). Run the command "Ntpdate 203.117.180.36", and then view the time through the date command, and discover that the time has been updated. Iv. Relevant KnowledgeLinux Clock Linux machine has two clocks, one is the hardware clock (CMOS clock), one is the kernel clock. The hardware clock is battery-powered and works through a dedicated chip. Can be set through the BIOS Setup screen or some system commands (such as Hwclock). The kernel clock is maintained by the kernel, which reads from the hardware at boot time and runs independently. The RTC (real time Clock), the real-time Linux clock drive, is usually embedded in the computer's chip, and some are implemented using Motorola MC146818 (or clone) on the motherboard. The hardware device can be mapped to/DEV/RTC for root programmatic access. NTP (Network Time Protocol) NTP is a network protocol, which is a way to ensure that hosts on the network adjust their time. The NTP server (ISP or NMS) is available in many places and can be found in [url]http://www.eecis.udel.edu/~mills/ntp/clock[/url]1a.html to find a recent server].

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.