Moxa DA-682A-C7-W7E [12/112] Setting a time manually

Moxa DA-682A-C7-W7E [12/112] Setting a time manually
DA-682A Linux Softrware Software Configuration
2-6
Use the command #init q to re-initialize the kernel.
moxa@MOXA:~# init q
NOTE
In *nix environments, when inserting a single line at the end of a configuration file it is possible to use a single
line command. This allows administrators to save time without opening the config file in an edtor. To insert a
single ine to the end of a file, use the
echo command with input redirects:
moxa@MOXA:~# echo “ntp : 2345 : respawn : /etc/init.d/fixtime”
>> /etc/inittab
Keep in mind, however, that care must be taken to use a
double caret (>>)
. Use of a single caret (>) indicates
overwriting the entire file with the single line, and will erase the current configuration.
Setting a Time Manually
System Time
When called with unquoted arguments, the date command will reset the system clock. The time and date must
be entered in the format of Month-Date-Hour-Minute-Year.
moxa@MOXA:~# date [MMDDhhmmYYYY]
Month, date, hour, and minute are all entered in a two digit code, with the year entered using the full four digits,
as shown below:
MM: Month
DD: Date
hhmm: Hour and Minute
YYYY: Year
moxa@MOXA:~# date
Tue Aug 20 11:28:05 CST 2013
moxa@MOXA:~# sudo hwclock
[sudo] password for moxa:
Tue 20 Aug 2013 11:28:47 AM CST -0.422555 seconds
moxa@MOXA:~# date 121616352009
Wed Dec 16 16:35:00 CST 2009
moxa@MOXA:~# sudo hwclock –w
moxa@MOXA:~# date ; sudo hwclock
Wed Dec 16 16:36:12 CST 2009
Wed 16 Dec 2009 03:38:13 AM CST -0.016751 seconds
Setting the RTC
After setting the system time, use hwclock to write the current system time to the RTC, as follows:
Moxa~# hwclock –w
Enabling and Disabling Daemons
To run a custom daemon (i.e., an automated background process called by the system), you should create an
inititalization script; this process was briefly described above, in the section Using a Shell Script for
Automatic Updates. While some people use rc.local to enable daemons, this practice is frowned upon and
can lead to cases where services or background processes that require a clean exit are broken at shut-down,
and will fail to start again at the next reboot. For this reason, best practices dictate that users who wish to set
up a scripted process to run in the background should use inittab and an init script to guarantee the process will
be cleanly managed, and any errors cleanly handled by the system.
After scripting a background process, for security’s sake and convenience of administration, the script should
be saved in
/usr/sbin and then then linked to from /etc/rc.local. Then, an initialization script (init script)
should be created, saved into
/etc/init.d, and logged into /etc/inittab (for more on this, see above,
How to run a shell script automatically across re-boots). A stripped down sample initialization
script is given below, in appendix C, Sample Scripts; you may use either the sample script below, or you may

Содержание

Похожие устройства