Moxa DA-681A-I-DPP-T-LX [12/79] Updating the time automatically

Moxa DA-681A-I-DPP-T-LX [12/79] Updating the time automatically
DA-681A Series Linux Software Configuration
2-5
Updating the Time Automatically
This section describes how to use a shell script to update the time automatically.
Example shell script for updating the system time periodically
#!/bin/sh
ntpdate time.stdtime.gov.tw
# 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 –w
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. For example, fixtime.
How to run the shell script automatically when the kernel boots up
Copy the example shell script fixtime to directory /etc/init.d, and then use chmod 755 fixtime to change
the shell script mode.
moxa@Moxa:~# chmod 755 fixtime
Next, use vi editor to edit the file /etc/inittab.
moxa@Moxa:~# vi /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-initialize the kernel.
moxa@Moxa:~# init q
Enabling and Disabling Daemons
Only the following daemons are enabled in the DA-681A by default:
sftpd SFTP Server / Client daemon
sshd Secure Shell Server daemon
You may manage what services to run in the background by the command insserv. Below example shows how
to add the apache daemon in current runlevel.
moxa@Moxa:~$ sudo insserv –d apache2
Apache will not activate in the current boot session, but will be running in the background from the next boot
session. To disable the apache daemon, use the following command:
moxa@Moxa:~$ sudo insserv -r apache2

Содержание

Скачать