⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setclock.html

📁 lfs3.1 从源代码构建linux。html版本。
💻 HTML
字号:
<HTML><HEAD><TITLE>Creating the setclock script</TITLE><METANAME="GENERATOR"CONTENT="Modular DocBook HTML Stylesheet Version 1.63"><LINKREL="HOME"TITLE="Linux From Scratch"HREF="../index.html"><LINKREL="UP"TITLE="Creating system boot scripts"HREF="../chapter07/chapter07.html"><LINKREL="PREVIOUS"TITLE="Creating the sendsignals script"HREF="../chapter07/sendsignals.html"><LINKREL="NEXT"TITLE="Creating the sysklogd script"HREF="../chapter07/sysklogd.html"></HEAD><BODYCLASS="sect1"BGCOLOR="#FFFFFF"TEXT="#000000"LINK="#0000FF"VLINK="#840084"ALINK="#0000FF"><DIVCLASS="NAVHEADER"><TABLEWIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><THCOLSPAN="3"ALIGN="center">Linux From Scratch: Version 3.1</TH></TR><TR><TDWIDTH="10%"ALIGN="left"VALIGN="bottom"><AHREF="../chapter07/sendsignals.html">Prev</A></TD><TDWIDTH="80%"ALIGN="center"VALIGN="bottom">Chapter 7. Creating system boot scripts</TD><TDWIDTH="10%"ALIGN="right"VALIGN="bottom"><AHREF="../chapter07/sysklogd.html">Next</A></TD></TR></TABLE><HRALIGN="LEFT"WIDTH="100%"></DIV><DIVCLASS="sect1"><H1CLASS="sect1"><ANAME="ch07-setclock">7.13. Creating the setclock script</A></H1><P>The following script is only for real use when the hardware clock (alsoknown as BIOS or CMOS clock) isn't set to GMT time. The recommendedsetup is setting the hardware clock to GMT and having the time convertedto localtime using the /etc/localtime symbolic link. But if anOS is run that doesn't understand a clock set to GMT (most notable areMicrosoft OS'es) you may want to set the clock to localtime so thatthe time is properly displayed on those OS'es. This script will then set the kernel time to the hardware clock without converting the time usingthe /etc/localtime symlink.</P><P>Create the <TTCLASS="filename">/etc/init.d/setclock</TT> script by runningthe following command:</P><P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="100%"><TR><TD><FONTCOLOR="#000000"><PRECLASS="screen"><TTCLASS="userinput"><B>cat &#62; /etc/init.d/setclock &#60;&#60; "EOF"</B></TT>#!/bin/sh# Begin /etc/init.d/setclock## Include the functions declared in the /etc/init.d/functions file# and include the variables from the /etc/sysconfig/clock file#source /etc/init.d/functionssource /etc/sysconfig/clock## Right now we want to set the kernel clock according to the hardware# clock, so we use the -hctosys parameter.#CLOCKPARAMS="--hctosys"## If the UTC variable is set in the /etc/sysconfig/clock file, add the# -u parameter as well which tells hwclock that the hardware clock is# set to UTC time instead of local time.#case "$UTC" in        yes|true|1)                CLOCKPARAMS="$CLOCKPARAMS --utc"                ;;        no|false|0)                CLOCKPARAMS="$CLOCKPARAMS --localtime"                ;;esacecho -n "Setting clock..."/sbin/hwclock $CLOCKPARAMSevaluate_retval# End /etc/init.d/setclock<TTCLASS="userinput"><B>EOF</B></TT></PRE></FONT></TD></TR></TABLE></P><DIVCLASS="sect2"><H2CLASS="sect2"><ANAME="AEN4317">7.13.1. Creating the /etc/sysconfig/clock file</A></H2><P>If you want to use this script on your system even if thehardware clock is set to GMT, then the UTC variable below has to bechanged to the value of <EM>1</EM>.</P><P>Create a new file <TTCLASS="filename">/etc/sysconfig/clock</TT> by runningthe following:</P><P><TABLEBORDER="0"BGCOLOR="#E0E0E0"WIDTH="100%"><TR><TD><FONTCOLOR="#000000"><PRECLASS="screen"><TTCLASS="userinput"><B>cat &#62; /etc/sysconfig/clock &#60;&#60; "EOF"</B></TT># Begin /etc/sysconfig/clockUTC=0# End /etc/sysconfig/clock<TTCLASS="userinput"><B>EOF</B></TT></PRE></FONT></TD></TR></TABLE></P><P>Now, you may want to take a look at a very good hint explaining how wedeal with time on LFS at <AHREF="http://hints.linuxfromscratch.org/hints/time.txt"TARGET="_top">http://hints.linuxfromscratch.org/hints/time.txt</A>. It explains issues such as timezones, UTC, and the TZ environment variable.</P></DIV></DIV><DIVCLASS="NAVFOOTER"><HRALIGN="LEFT"WIDTH="100%"><TABLEWIDTH="100%"BORDER="0"CELLPADDING="0"CELLSPACING="0"><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top"><AHREF="../chapter07/sendsignals.html">Prev</A></TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="../index.html">Home</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top"><AHREF="../chapter07/sysklogd.html">Next</A></TD></TR><TR><TDWIDTH="33%"ALIGN="left"VALIGN="top">Creating the sendsignals script</TD><TDWIDTH="34%"ALIGN="center"VALIGN="top"><AHREF="../chapter07/chapter07.html">Up</A></TD><TDWIDTH="33%"ALIGN="right"VALIGN="top">Creating the sysklogd script</TD></TR></TABLE></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -