Moxa DA-682A-C7-DPP [13/108] Setting the rtc

Moxa DA-682A-C7-DPP [13/108] Setting the rtc
DA-682A-DPP Linux Software Software Configuration
2-7
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
initialization 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 canuse the sample script below, or use the script
provided with the standard Debian distribution, which is available at
/etc/init.d/skeleton. (the skeleton
script provides a great deal more commentary and features). The complete process is described below.
1. Copy your custom script to /usr/sbin using the convention of rc<scriptname>:
moxa@Moxa:~# cp <full-path-to-your-program> /usr/sbin/rc<scriptname>
2. Give this script executable permissions:
moxa@Moxa:~# chmod 755 /usr/sbin/rc<scriptname>
3. Make a copy of the sample file at /etc/init.d/skeleton (or the one provided in Appendix C of this
manual) and edit it to create an initialization script for your program.
moxa@Moxa:~# cp /etc/init.d/skeleton /etc/init.d/<scriptname>
4. Give the initialization script executable permissions.
moxa@Moxa:~# chmod 755 /etc/init.d/<scriptname>
5. Now activate your script so that it can be run when the system boots; use a low startup priority (below we
use 97 for starts, 03 for shutdown).
moxa@Moxa:~# update-rc.d <scriptname> default 97 03
ATTENTION
For more details about which systems in a Linux environment should be used for automated scripting and
processes,
refer to the webpage http://bencane.com/2011/12/30/when-its-ok-and-not-ok-to-use-rc-local/
(Nov, 2013). For more information about creating custom Linux scripts, refer to
http://www.linux
.com/learn/tutorials/442412-managing-linux-daemons-with-init-scripts

Содержание

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

Скачать