Moxa RM-1050-T [23/52] Updating the time with ntp client

Moxa KM-2430-T [23/52] Updating the time with ntp client
ioPAC RTU Software RTU Management
3-9
Updating the Time with NTP Client
The ioPAC RTU controller 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
Visit http://www.ntp.org for more information about NTP and NTP server addresses.
root@Moxa:/# date ;hwclock
Fri May 10 10:50:54 CST 2013
Fri May 10 02:50:53 2013 0.000000 seconds
root@Moxa:/# ntpdate time.stdtion.gov.tw
10 May 10:51:03 ntpdate[156]: adjust time server 192.168.50.33 offset 0.007500 sec
root@Moxa:/# hwclock -w
root@Moxa:/# date; hwclock
Fri May 10 10:51:17 CST 2013
Fri May 10 10:51:16 2013 0.000000 seconds
root@Moxa:/#
Add the command line to the vi/etc/profile directory to change the time zone. For example, export
TZ=CST-8.
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
s information.
Updating the Time Automatically
This section demonstrates 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.
Save the shell script using any file name (e.g., fixtime)
How to run the shell script automatically when the kernel boots up
Copy the above example shell script fixtime to directory /etc/init.d, and then use chmod 755 fixtime to change
the shell script mode. Next, use vi editor to edit the file /etc/inittab. Add the following line to the bottom of the
file:
ntp : 2345 : respawn : /etc/init.d/fixtime
Use the command #init q to re-init the kernel.

Содержание

Скачать