Ntp client, Updating the time automatically, Ntp client -10 – Moxa Technologies UC-7420/7410 User Manual
Page 50: Updating the time automatically -10
UC-7420/7410 User’s Manual
Managing Embedded Linux
3-10
192.168.3.127 – PuTTY
root@Moxa:~# date
Fri Jun 23 23:30:31 CST 2000
root@Moxa:~# hwclock
Fri Jun 23 23:30:35 2000 -0.557748 seconds
root@Moxa:~# date 120910002004
Thu Dec 9 10:00:00 CST 2004
root@Moxa:~# hwclock –w
root@Moxa:~# date ; hwclock
Thu Dec 9 10:01:07 CST 2004
Thu Dec 9 10:01:08 2004 -0.933547 seconds
root@Moxa:~#
NTP Client
UC-7420/7410 has a built-in NTP (Network Time Protocol) client that is used to initialize a time
request to a remote NTP server. Use #ntpdate <this client utility> to update the system
time.
#ntpdate time.stdtime.gov.tw
#hwclock –w
for more information about NTP and NTP server addresses.
10.120.53.100 – PuTTY
root@Moxa:~# date ; hwclock
Sat Jan 1 00:00:36 CST 2000
Sat Jan 1 00:00:37 2000 -0.772941 seconds
root@Moxa:~# ntpdate time.stdtion.gov.tw
9 Dec 10:58:53 ntpdate[207]: step time server 220.130.158.52 offset 155905087.9
84256 sec
root@Moxa:~# hwclock -w
root@Moxa:~# date ; hwclock
Thu Dec 9 10:59:11 CST 2004
Thu Dec 9 10:59:12 2004 -0.844076 seconds
root@Moxa:~#
NOTE
Before using the NTP client utility, check your IP and DNS settings to make sure that an Internet
connection is available. Refer to Chapter 2 for instructions on how to configure the Ethernet
interface, and see Chapter 4 for DNS setting information.
Updating the Time Automatically
In this subsection we show how to use a shell script to update the time automatically.
Example shell script to update the system time periodically
#!/bin/sh
ntpdate time.nist.gov # You can use the time server’s ip address or domain
# name directly. If you use domain name, you must
# enable the domain client on the system by updating
#
/etc/resolv.conf
file.
hwclock –systohc
sleep 100 # Updates every 100 seconds. The min. time is 100 seconds. Change
# 100 to a larger number to update RTC less often.