📄 setclock.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=gb2312" />
<title>
7.5. Configuring the setclock Script
</title>
<link rel="stylesheet" href="../stylesheets/lfs.css" type="text/css" />
<meta name="generator" content="DocBook XSL Stylesheets V1.68.1" />
<link rel="stylesheet" href="../stylesheets/lfs-print.css" type="text/css" media="print" />
</head>
<body id="lfs" class="6.1">
<div class="navheader">
<div class="headertitles">
<h4>
Linux From Scratch - Version 6.1
</h4>
<h3>
Chapter 7. 配置系统启动脚本(Bootscripts)
</h3>
</div>
<ul class="headerlinks">
<li class="prev">
<a accesskey="p" href="udev.html" title="Device and Module Handling on an LFS System">后退</a>
<p>
Device and Module Handling on an LFS System
</p>
</li>
<li class="next">
<a accesskey="n" href="console.html" title="Configuring the Linux Console">前进</a>
<p>
Configuring the Linux Console
</p>
</li>
<li class="up">
<a accesskey="u" href="chapter07.html" title="Chapter 7. 配置系统启动脚本(Bootscripts)">上一级</a>.
</li>
<li class="home">
<a accesskey="h" href="../index.html" title="Linux From Scratch - Version 6.1">回首页</a>
</li>
</ul>
</div>
<div class="sect1" lang="zh_cn" xml:lang="zh_cn">
<div class="titlepage">
<h1 class="sect1">
7.5. 配置 setclock 脚本 </h1>
</div>
<p><span><strong class="command">setclock</strong></span> 脚本从硬件时钟,也就是 BIOS 或 CMOS时钟读取时间。如果硬件时钟设置为 UTC,这个脚本会使用 <tt class="filename">/etc/localtime</tt> 文件(这个文件把用户所在的时区告诉
<span><strong class="command">hwclock</strong></span> 程序)将硬件时钟的时间转换为本地时间。没有办法自动检测硬件时钟是否设置为 UTC 时间,因此需要手动设置。</p>
<p>
如果您忘了硬件时钟是不是设置为 UTC 时间了,可以运行 <strong class="userinput"><tt>hwclock
--localtime --show</tt></strong> 命令,这将显示硬件时钟当前的时间。如果显示的时间符合您的手表的时间,那么硬件时钟设置的是本地时间;如果 <span><strong class="command">hwclock</strong></span> 显示的不是本地时间,就有可能设置的是 UTC 时间,可以通过在所显示的
<span><strong class="command">hwclock</strong></span>时间加上或减去您所在时区的小时数来验证。例如,如果您所在的时区是 MST(美国山区时区),已知是 GMT -0700,在本地时间上加 7 小时。</p>
<p>
运行下面的命令新建一个 <tt class="filename">/etc/sysconfig/clock</tt> 文件(<kbd class="command"><tt class="literal">UTC=1 表示使用的是UTC时间</tt></kbd>):</p>
<pre class="userinput"><kbd class="command">cat > /etc/sysconfig/clock << "EOF"
<tt class="literal"># Begin /etc/sysconfig/clock
UTC=1
# End /etc/sysconfig/clock</tt>
EOF</kbd></pre>
<p>如果硬件时间<span class="emphasis"><em>没有</em></span>设置为 <tt class="envar">UTC</tt> 时间,请将上面的 <tt class="envar">UTC</tt> 变量设置为 <em class="parameter"><tt>0</tt></em> (零)。
</p>
<p>
在
<a href="http://www.linuxfromscratch.org/hints/downloads/files/time.txt"><i>http://www.linuxfromscratch.org/hints/downloads/files/time.txt</i></a> 有一个很好的关于如何处理 LFS 时间的提示,说明了例如时区、UTC、<tt class="envar">TZ</tt> 环境变量等等问题。</p>
</div>
<div class="navfooter">
<ul>
<li class="prev">
<a accesskey="p" href="udev.html" title="Device and Module Handling on an LFS System">后退</a>
<p>
Device and Module Handling on an LFS System
</p>
</li>
<li class="next">
<a accesskey="n" href="console.html" title="Configuring the Linux Console">前进</a>
<p>
Configuring the Linux Console
</p>
</li>
<li class="up">
<a accesskey="u" href="chapter07.html" title="Chapter 7. 配置系统启动脚本(Bootscripts)">上一级</a>.
</li>
<li class="home">
<a accesskey="h" href="../index.html" title="Linux From Scratch - Version 6.1">回首页</a>.
</li>
</ul>
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -