777 lines
31 KiB
HTML
777 lines
31 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
|
|
|
|
<title>Debian GNU/Linux System Administrator's Manual (Obsolete Documentation) - Time</title>
|
|
|
|
<link href="index.html" rel="start">
|
|
<link href="ch-sysadmin-config.html" rel="prev">
|
|
<link href="ch-sysadmin-localisation.html" rel="next">
|
|
<link href="index.html#contents" rel="contents">
|
|
<link href="index.html#copyright" rel="copyright">
|
|
<link href="ch-sysadmin-intro.html" rel="chapter" title="1 Introduction">
|
|
<link href="ch-sysadmin-overview.html" rel="chapter" title="2 Overview of a Debian GNU/Linux System">
|
|
<link href="ch-sysadmin-files.html" rel="chapter" title="3 Files and Devices">
|
|
<link href="ch4.html" rel="chapter" title="4 Programs and processes">
|
|
<link href="ch-sysadmin-directories.html" rel="chapter" title="5 Directory Structure">
|
|
<link href="ch-sysadmin-filesystems.html" rel="chapter" title="6 Filesystems and Storage Media">
|
|
<link href="ch-sysadmin-booting.html" rel="chapter" title="7 Boot and Shutdown">
|
|
<link href="ch-sysadmin-users.html" rel="chapter" title="8 Managing User Accounts">
|
|
<link href="ch-sysadmin-sessions.html" rel="chapter" title="9 Logging In and Out">
|
|
<link href="ch-sysadmin-printing.html" rel="chapter" title="10 Printing">
|
|
<link href="ch-sysadmin-accounting.html" rel="chapter" title="11 Accounting">
|
|
<link href="ch-sysadmin-backup.html" rel="chapter" title="12 Backup and Restore">
|
|
<link href="ch-sysadmin-X.html" rel="chapter" title="13 X Windows">
|
|
<link href="ch-sysadmin-security.html" rel="chapter" title="14 Security">
|
|
<link href="ch-sysadmin-config.html" rel="chapter" title="15 System Configuration">
|
|
<link href="ch-sysadmin-time.html" rel="chapter" title="16 Time">
|
|
<link href="ch-sysadmin-localisation.html" rel="chapter" title="17 Localisation">
|
|
<link href="ch-sysadmin-index.html" rel="chapter" title="18 Index">
|
|
<link href="ch-sysadmin-intro.html#s1.1" rel="section" title="1.1 About this manual">
|
|
<link href="ch-sysadmin-intro.html#s1.2" rel="section" title="1.2 Where to find newer versions">
|
|
<link href="ch-sysadmin-intro.html#s1.3" rel="section" title="1.3 Comments">
|
|
<link href="ch-sysadmin-overview.html#s2.1" rel="section" title="2.1 The main components of a system">
|
|
<link href="ch-sysadmin-files.html#s3.1" rel="section" title="3.1 Files">
|
|
<link href="ch-sysadmin-files.html#s3.2" rel="section" title="3.2 Devices">
|
|
<link href="ch4.html#s4.1" rel="section" title="4.1 Programs">
|
|
<link href="ch4.html#s4.2" rel="section" title="4.2 Processes">
|
|
<link href="ch4.html#s4.3" rel="section" title="4.3 The /proc filesystem">
|
|
<link href="ch4.html#s4.4" rel="section" title="4.4 Tools for handling programs and processes">
|
|
<link href="ch-sysadmin-directories.html#s5.1" rel="section" title="5.1 Directories">
|
|
<link href="ch-sysadmin-directories.html#s5.2" rel="section" title="5.2 Permissions">
|
|
<link href="ch-sysadmin-directories.html#s5.3" rel="section" title="5.3 Links">
|
|
<link href="ch-sysadmin-directories.html#s5.4" rel="section" title="5.4 ACL - Access Control Lists">
|
|
<link href="ch-sysadmin-directories.html#s5.5" rel="section" title="5.5 Tools for managing directories">
|
|
<link href="ch-sysadmin-filesystems.html#s6.1" rel="section" title="6.1 Storage devices and media">
|
|
<link href="ch-sysadmin-filesystems.html#s6.2" rel="section" title="6.2 Types of filesystem">
|
|
<link href="ch-sysadmin-filesystems.html#s6.3" rel="section" title="6.3 Quotas">
|
|
<link href="ch-sysadmin-filesystems.html#s6.4" rel="section" title="6.4 Tools for managing filesystems">
|
|
<link href="ch-sysadmin-booting.html#s7.1" rel="section" title="7.1 Boot loaders">
|
|
<link href="ch-sysadmin-users.html#s8.1" rel="section" title="8.1 Concepts">
|
|
<link href="ch-sysadmin-users.html#s8.2" rel="section" title="8.2 Common tasks">
|
|
<link href="ch-sysadmin-users.html#s8.3" rel="section" title="8.3 Tools reference">
|
|
<link href="ch-sysadmin-users.html#s8.4" rel="section" title="8.4 Files reference">
|
|
<link href="ch-sysadmin-sessions.html#s9.1" rel="section" title="9.1 Starting a session - logging in">
|
|
<link href="ch-sysadmin-printing.html#s10.1" rel="section" title="10.1 Print devices">
|
|
<link href="ch-sysadmin-printing.html#s10.2" rel="section" title="10.2 Spooler">
|
|
<link href="ch-sysadmin-accounting.html#s11.1" rel="section" title="11.1 Concepts">
|
|
<link href="ch-sysadmin-backup.html#s12.1" rel="section" title="12.1 Why backup?">
|
|
<link href="ch-sysadmin-backup.html#s12.2" rel="section" title="12.2 What to backup?">
|
|
<link href="ch-sysadmin-backup.html#s12.3" rel="section" title="12.3 Backup devices and media">
|
|
<link href="ch-sysadmin-backup.html#s12.4" rel="section" title="12.4 Backup methods and software">
|
|
<link href="ch-sysadmin-backup.html#s12.5" rel="section" title="12.5 Types of backup">
|
|
<link href="ch-sysadmin-X.html#s13.1" rel="section" title="13.1 Overview of X">
|
|
<link href="ch-sysadmin-security.html#s14.1" rel="section" title="14.1 Threats">
|
|
<link href="ch-sysadmin-config.html#s15.1" rel="section" title="15.1 ???">
|
|
<link href="ch-sysadmin-time.html#s16.1" rel="section" title="16.1 Setting time, time zones and Daylight Saving">
|
|
<link href="ch-sysadmin-time.html#s16.2" rel="section" title="16.2 Setting and showing hardware clock">
|
|
<link href="ch-sysadmin-time.html#s-multiboot-with" rel="section" title="16.3 Multiboot with operating systems not understanding timezone">
|
|
<link href="ch-sysadmin-time.html#s-syncing-time" rel="section" title="16.4 Syncing time, rdate and NTP">
|
|
<link href="ch-sysadmin-time.html#s16.5" rel="section" title="16.5 Setting up an NTP server">
|
|
<link href="ch-sysadmin-time.html#s-radio-clocks" rel="section" title="16.6 Radio clocks">
|
|
<link href="ch-sysadmin-time.html#s16.7" rel="section" title="16.7 Timestamps">
|
|
<link href="ch-sysadmin-time.html#s16.8" rel="section" title="16.8 Time in cron">
|
|
<link href="ch-sysadmin-localisation.html#s17.1" rel="section" title="17.1 Environment variables">
|
|
<link href="ch-sysadmin-overview.html#s2.1.1" rel="subsection" title="2.1.1 The hardware">
|
|
<link href="ch-sysadmin-overview.html#s2.1.2" rel="subsection" title="2.1.2 The Linux kernel">
|
|
<link href="ch-sysadmin-overview.html#s2.1.3" rel="subsection" title="2.1.3 Devices">
|
|
<link href="ch-sysadmin-overview.html#s2.1.4" rel="subsection" title="2.1.4 Filesystems">
|
|
<link href="ch-sysadmin-files.html#s3.1.1" rel="subsection" title="3.1.1 Concepts">
|
|
<link href="ch-sysadmin-files.html#s3.1.2" rel="subsection" title="3.1.2 Inodes">
|
|
<link href="ch-sysadmin-files.html#s3.1.3" rel="subsection" title="3.1.3 Links">
|
|
<link href="ch-sysadmin-files.html#s3.1.4" rel="subsection" title="3.1.4 Permissions">
|
|
<link href="ch-sysadmin-files.html#s3.2.1" rel="subsection" title="3.2.1 Device drivers">
|
|
<link href="ch-sysadmin-files.html#s3.2.2" rel="subsection" title="3.2.2 Device nodes">
|
|
<link href="ch-sysadmin-files.html#s3.2.3" rel="subsection" title="3.2.3 Kernel modules">
|
|
<link href="ch-sysadmin-directories.html#s5.3.1" rel="subsection" title="5.3.1 Hard links">
|
|
<link href="ch-sysadmin-directories.html#s5.3.2" rel="subsection" title="5.3.2 Symbolic links">
|
|
<link href="ch-sysadmin-users.html#s8.1.1" rel="subsection" title="8.1.1 Usernames and User IDs">
|
|
<link href="ch-sysadmin-users.html#s8.1.2" rel="subsection" title="8.1.2 Groups and Group IDs">
|
|
<link href="ch-sysadmin-users.html#s8.1.3" rel="subsection" title="8.1.3 Passwords">
|
|
<link href="ch-sysadmin-users.html#s8.1.4" rel="subsection" title="8.1.4 Quotas">
|
|
<link href="ch-sysadmin-users.html#s8.2.1" rel="subsection" title="8.2.1 Adding new users">
|
|
<link href="ch-sysadmin-users.html#s8.2.2" rel="subsection" title="8.2.2 Changing or editing user information and settings">
|
|
<link href="ch-sysadmin-users.html#s8.2.3" rel="subsection" title="8.2.3 Removing user accounts">
|
|
<link href="ch-sysadmin-users.html#s8.2.4" rel="subsection" title="8.2.4 Changing user passwords">
|
|
<link href="ch-sysadmin-users.html#s8.2.5" rel="subsection" title="8.2.5 Setting and changing password expiry times">
|
|
<link href="ch-sysadmin-users.html#s8.2.6" rel="subsection" title="8.2.6 Creating groups">
|
|
<link href="ch-sysadmin-users.html#s8.2.7" rel="subsection" title="8.2.7 Editing groups">
|
|
<link href="ch-sysadmin-users.html#s8.2.8" rel="subsection" title="8.2.8 Deleting groups">
|
|
<link href="ch-sysadmin-users.html#s8.2.9" rel="subsection" title="8.2.9 Setting up quotas">
|
|
<link href="ch-sysadmin-users.html#s8.2.10" rel="subsection" title="8.2.10 Using shadow passwords">
|
|
<link href="ch-sysadmin-users.html#s8.3.1" rel="subsection" title="8.3.1 Command-line tools">
|
|
<link href="ch-sysadmin-users.html#s8.3.1.1" rel="subsection" title="8.3.1.1 adduser, addgroup">
|
|
<link href="ch-sysadmin-users.html#s8.3.1.2" rel="subsection" title="8.3.1.2 chage">
|
|
<link href="ch-sysadmin-users.html#s8.3.1.3" rel="subsection" title="8.3.1.3 chfn">
|
|
<link href="ch-sysadmin-users.html#s8.3.1.4" rel="subsection" title="8.3.1.4 chsh">
|
|
<link href="ch-sysadmin-users.html#s8.3.1.5" rel="subsection" title="8.3.1.5 passwd">
|
|
<link href="ch-sysadmin-users.html#s8.3.1.6" rel="subsection" title="8.3.1.6 userdel">
|
|
<link href="ch-sysadmin-users.html#s8.3.1.7" rel="subsection" title="8.3.1.7 vipw, vigr">
|
|
<link href="ch-sysadmin-users.html#s8.3.2" rel="subsection" title="8.3.2 Graphical tools">
|
|
<link href="ch-sysadmin-users.html#s8.4.1" rel="subsection" title="8.4.1 /etc/passwd">
|
|
<link href="ch-sysadmin-users.html#s8.4.2" rel="subsection" title="8.4.2 /etc/group">
|
|
<link href="ch-sysadmin-users.html#s8.4.3" rel="subsection" title="8.4.3 /etc/shadow">
|
|
<link href="ch-sysadmin-printing.html#s10.2.1" rel="subsection" title="10.2.1 Lp">
|
|
<link href="ch-sysadmin-printing.html#s10.2.2" rel="subsection" title="10.2.2 LPrng">
|
|
<link href="ch-sysadmin-backup.html#s-sect-floppy" rel="subsection" title="12.3.1 Floppy">
|
|
<link href="ch-sysadmin-backup.html#s12.3.1.1" rel="subsection" title="12.3.1.1 Backup example 1, suitable for disk media">
|
|
<link href="ch-sysadmin-backup.html#s12.3.1.2" rel="subsection" title="12.3.1.2 Backup example 2, suitable for tape media">
|
|
<link href="ch-sysadmin-backup.html#s12.3.1.3" rel="subsection" title="12.3.1.3 Backup example 3, suitable for disk media with DOS file system">
|
|
<link href="ch-sysadmin-backup.html#s12.3.2" rel="subsection" title="12.3.2 High Capacity Floppies">
|
|
<link href="ch-sysadmin-backup.html#s12.3.3" rel="subsection" title="12.3.3 CD-R and CD-RW">
|
|
<link href="ch-sysadmin-backup.html#s12.3.4" rel="subsection" title="12.3.4 Tapes">
|
|
<link href="ch-sysadmin-backup.html#s12.4.1" rel="subsection" title="12.4.1 Network backups">
|
|
<link href="ch-sysadmin-backup.html#s12.4.1.1" rel="subsection" title="12.4.1.1 Installing EMC NetWorker Client">
|
|
<link href="ch-sysadmin-backup.html#s12.4.1.2" rel="subsection" title="12.4.1.2 Setting up and Configuring">
|
|
<link href="ch-sysadmin-backup.html#s12.4.2" rel="subsection" title="12.4.2 Tar et al">
|
|
<link href="ch-sysadmin-backup.html#s12.4.3" rel="subsection" title="12.4.3 Backup software">
|
|
<link href="ch-sysadmin-time.html#s-tzconfig" rel="subsection" title="16.1.1 Changing the timezone after installation">
|
|
<link href="ch-sysadmin-time.html#s16.1.2" rel="subsection" title="16.1.2 Setting the TZ environment variable.">
|
|
<link href="ch-sysadmin-time.html#s16.4.1" rel="subsection" title="16.4.1 Setting time at system boot">
|
|
<link href="ch-sysadmin-time.html#s16.4.2" rel="subsection" title="16.4.2 Setting time using NTP">
|
|
<link href="ch-sysadmin-time.html#s16.4.3" rel="subsection" title="16.4.3 Other methods">
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<p><a name="ch-sysadmin-time"></a></p>
|
|
<hr>
|
|
|
|
<p>
|
|
[ <a href="ch-sysadmin-config.html">previous</a> ]
|
|
[ <a href="index.html#contents">Contents</a> ]
|
|
[ <a href="ch-sysadmin-intro.html">1</a> ]
|
|
[ <a href="ch-sysadmin-overview.html">2</a> ]
|
|
[ <a href="ch-sysadmin-files.html">3</a> ]
|
|
[ <a href="ch4.html">4</a> ]
|
|
[ <a href="ch-sysadmin-directories.html">5</a> ]
|
|
[ <a href="ch-sysadmin-filesystems.html">6</a> ]
|
|
[ <a href="ch-sysadmin-booting.html">7</a> ]
|
|
[ <a href="ch-sysadmin-users.html">8</a> ]
|
|
[ <a href="ch-sysadmin-sessions.html">9</a> ]
|
|
[ <a href="ch-sysadmin-printing.html">10</a> ]
|
|
[ <a href="ch-sysadmin-accounting.html">11</a> ]
|
|
[ <a href="ch-sysadmin-backup.html">12</a> ]
|
|
[ <a href="ch-sysadmin-X.html">13</a> ]
|
|
[ <a href="ch-sysadmin-security.html">14</a> ]
|
|
[ <a href="ch-sysadmin-config.html">15</a> ]
|
|
[ 16 ]
|
|
[ <a href="ch-sysadmin-localisation.html">17</a> ]
|
|
[ <a href="ch-sysadmin-index.html">18</a> ]
|
|
[ <a href="ch-sysadmin-localisation.html">next</a> ]
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<h1>
|
|
Debian GNU/Linux System Administrator's Manual (Obsolete Documentation)
|
|
<br>Chapter 16 - Time
|
|
</h1>
|
|
|
|
<hr>
|
|
|
|
<p>
|
|
<code><a href="mailto:Tapio.Lehtonen@IKI.FI">Tapio.Lehtonen@IKI.FI</a></code>
|
|
</p>
|
|
|
|
<p>
|
|
Computers have a <strong>clock</strong> to keep time. Usually there is a
|
|
hardware clock with battery backup to keep time when the computer is off. The
|
|
operating system (for example Linux) runs its own clock, and from this clock
|
|
comes the time shown by commands such as <code>date</code> in Linux and
|
|
<code>time</code> in DOS.
|
|
</p>
|
|
|
|
<p>
|
|
The hardware clock is usually accurate enough, provided that the battery has
|
|
not run out. If the time shown by the computer when you turn it on is wrong by
|
|
several months or years, it is worth checking if the battery is still usable.
|
|
</p>
|
|
|
|
<p>
|
|
The "software" clock in the operating system usually has drift,
|
|
either systematic or random. This drift means the clock runs too fast or too
|
|
slow. For this reason it is nesessary to use some accurate time source to
|
|
syncronize the operating system clock if accurate time is needed.
|
|
</p>
|
|
|
|
<p>
|
|
To see the time on Debian GNU/Linux, use the command <code>date</code>. For
|
|
example
|
|
</p>
|
|
|
|
<pre>
|
|
$ date
|
|
Fri Oct 23 04:45:51 EEST 1998
|
|
</pre>
|
|
|
|
<p>
|
|
The above command shows the day of the week, the month, the day of the month,
|
|
the time, the time zone and the year. The time zone also shows whether
|
|
Daylight Saving Time is in use (in the example, the base time zone is EET,and
|
|
the extra S means Saving).
|
|
</p>
|
|
|
|
<p>
|
|
In Debian GNU/Linux and other Unix, the command <code>time</code> does not show
|
|
time. It is used to time command excecutions. If you have some command that
|
|
takes a fair amount of time to execute, and you do not feel like standing by
|
|
with a stopwatch, you can see how long it took by running the command as
|
|
argument to <code>time</code>. This example may clear things up:
|
|
</p>
|
|
|
|
<pre>
|
|
$ time sleep 60
|
|
|
|
real 1m0.045s
|
|
user 0m0.000s
|
|
sys 0m0.000s
|
|
</pre>
|
|
|
|
<p>
|
|
If You have root privileges, you can also change the time with the command
|
|
<code>date</code> (see the man page <code>date(1)</code>). If you are
|
|
connected to the Internet or have other Unix computers on your LAN, see <a
|
|
href="#s-syncing-time">Syncing time, rdate and NTP, Section 16.4</a> for easier
|
|
ways to set time.
|
|
</p>
|
|
|
|
<p>
|
|
When setting the time manually, the time string may be confusing. The command
|
|
<code>date --set</code> accepts the date and time in many formats. You can
|
|
read the sh-utils info document, or use the example below to figure out one
|
|
possible format. There date is given in ISO 8601 standard format YYYY-MM-DD
|
|
for Year-Month-DayOfMonth, and time of day using 24 hour clock. Leading zeros
|
|
are significant.
|
|
</p>
|
|
|
|
<pre>
|
|
date --set 1998-11-02
|
|
date --set 21:08:0
|
|
</pre>
|
|
|
|
<p>
|
|
The above two commands set the date to 2nd November 1998, and time to eight
|
|
minutes past 9pm.
|
|
</p>
|
|
|
|
<p>
|
|
To see the time in UTC, use command <code>date -u</code>.
|
|
</p>
|
|
|
|
<p>
|
|
If you are running X Window, you may have a clock display somewhere on the
|
|
screen. If not, you can obtain it by running the command <code>xclock</code>,
|
|
which is part of the <code>xbase</code> package. The bare <code>xclock</code>
|
|
command gives you an analog clock (with big hand, little hand, and an optional
|
|
seconds hand). You can get a digital clock (with <code>xclock
|
|
-digital</code>). See the man page <code>xclock(1)</code>for more information.
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<h2><a name="s16.1"></a>16.1 Setting time, time zones and Daylight Saving</h2>
|
|
|
|
<p>
|
|
When you installed the base system of Debian GNU/Linux, you set the
|
|
<strong>Timezone</strong>. You can check how you have set the Timezone by
|
|
looking at the file <code>/etc/timezone</code>. If you want to change the
|
|
timezone configuration, see <a href="#s-tzconfig">Changing the timezone after
|
|
installation, Section 16.1.1</a>.
|
|
</p>
|
|
|
|
<pre>
|
|
$ cat /etc/timezone
|
|
Europe/Helsinki
|
|
$
|
|
</pre>
|
|
|
|
<p>
|
|
The time zone is needed because Unix computers keep time in <strong>Universal
|
|
Time</strong> (<strong>UTC</strong>), and <strong>local time</strong> is
|
|
calculated from this. UTC is solar time on meridian 0. UTC was previously
|
|
called Greenwich Mean Time (GMT) because meridian 0 passes through the old
|
|
Royal Observatory in Greenwich, which is part of London, England.
|
|
</p>
|
|
|
|
<p>
|
|
UTC is constant, and is not subject to Daylight Saving Time or other changes.
|
|
This is what makes it useful for syncronising computers. As long as the base
|
|
time is kept in UTC, computers all over the world can be synchronised and yet
|
|
maintain their local time information.
|
|
</p>
|
|
|
|
<p>
|
|
If you were to set your Debian GNU/Linux computer to use local time, without
|
|
taking account of timezones, you would lose the benefit of automatic DST
|
|
changes. <strong>We do not recommend this!</strong> However, it may be
|
|
necessary to compromise by setting your hardware clock to local time (see <a
|
|
href="#s-multiboot-with">Multiboot with operating systems not understanding
|
|
timezone, Section 16.3</a>). In this document, we assume that you have
|
|
configured your computer to use UTC.
|
|
</p>
|
|
|
|
<p>
|
|
To change the computer to use UTC after installation, edit the file
|
|
<code>/etc/default/rcS</code>, change the variable <samp>UTC</samp> to
|
|
<samp>no</samp>. If you happened to install your system to use local time,
|
|
just change the variable to <samp>yes</samp> to start using UTC. It is best to
|
|
reboot after editing <code>/etc/default/rcS</code> to get the changes
|
|
effective.
|
|
</p>
|
|
|
|
<p>
|
|
If the Timezone is correctly set up, and the timezone configuration files are
|
|
reasonably current, the local time shown by the operating system will change to
|
|
<strong>Daylight Saving Time</strong> and back to normal time automatically on
|
|
the correct dates. If the timezone files you have are old, there may be
|
|
problems because DST start and end dates are not determined by a physical
|
|
phenomenon, but are chosen by national institutions. Sometimes these dates are
|
|
changed, for example, the European Union changed the end date from the last
|
|
Sunday in September to the last Sunday in October in 1995.
|
|
</p>
|
|
|
|
<p>
|
|
For this reason, you should make sure that your <code>libc6</code> package is
|
|
kept reasonably up to date. This package, from Debian GNU/Linux 2.2 onwards,
|
|
contains the timezone data.
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<h3><a name="s-tzconfig"></a>16.1.1 Changing the timezone after installation</h3>
|
|
|
|
<p>
|
|
If the timezone is not set or is wrong, the superuser can run
|
|
<code>tzconfig</code> to configure it after the operating system is installed
|
|
(see man page <code>tzconfig(8)</code>).
|
|
</p>
|
|
|
|
<p>
|
|
If there are other users, it is a good idea to notify then that the system
|
|
Timezone has changed.
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<h3><a name="s16.1.2"></a>16.1.2 Setting the TZ environment variable.</h3>
|
|
|
|
<p>
|
|
If you do not have root privileges or want to set for yourself a different
|
|
timezone than the one the system uses, you can set the environment variable
|
|
<samp>TZ</samp>. Use the command <code>tzselect</code> to show what value to
|
|
use for TZ.
|
|
</p>
|
|
|
|
<p>
|
|
Example on using TZ:
|
|
</p>
|
|
|
|
<pre>
|
|
$ date
|
|
Sun Nov 1 19:49:38 EET 1998
|
|
$ export TZ=PST
|
|
$ date
|
|
Sun Nov 1 17:49:59 PST 1998
|
|
</pre>
|
|
|
|
<p>
|
|
As you can see, for this user <code>date</code> shows a different time. (but
|
|
this seems wrong, since Pacific Standard Time should be 09:49???. What's
|
|
happening???).
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<h2><a name="s16.2"></a>16.2 Setting and showing hardware clock</h2>
|
|
|
|
<p>
|
|
The command for setting the hardware clock is <code>hwclock</code>. (This was
|
|
not in Debian before 2.0. In earlier releases, the command was
|
|
<code>clock</code>.)
|
|
</p>
|
|
|
|
<p>
|
|
If you use the <code>date</code> command to change time, it is worth setting
|
|
also the hardware clock to the correct time. Otherwise, the time is wrong
|
|
after the next reboot, since the hardware clock keeps the time when power is
|
|
turned off. When the clock in the operating system shows the correct time, set
|
|
the hardware clock like this:
|
|
</p>
|
|
|
|
<pre>
|
|
dilbert# date
|
|
Sun Nov 1 18:56:50 EET 1998
|
|
dilbert# hwclock --systohc --utc
|
|
dilbert#
|
|
</pre>
|
|
|
|
<p>
|
|
Remember to add the <code>--utc</code> -option if the hardware clock is set to
|
|
UTC!
|
|
</p>
|
|
|
|
<p>
|
|
See man page <code>hwclock(8)</code> for more information.
|
|
</p>
|
|
|
|
<p>
|
|
At least from Debian version 2.2 onwards, the system automatically saves the
|
|
system time to hardware clock on shutdown, and sets the system clock from
|
|
hardware clock when Debian boots up. This is done in the script
|
|
<code>/etc/init.d/hwclock.sh</code>.
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<h2><a name="s-multiboot-with"></a>16.3 Multiboot with operating systems not understanding timezone</h2>
|
|
|
|
<p>
|
|
If you have a multiboot configuration, where you have some other operating
|
|
system(s) on the same computer, and during boot choose which one to start, you
|
|
may get confused about the correct time. If the other operating systems do not
|
|
understand timezones, they think UTC is the local time and show the wrong time
|
|
(unless you live in London, England or some other place in the same timezone).
|
|
</p>
|
|
|
|
<p>
|
|
DOS, OS/2 and Windows except NT do not use timezones. If you <em>need</em> to
|
|
have the correct local time in these operating systems, you have to set the
|
|
clock to local time. Debian Linux can live with this and it works, but if your
|
|
main operating system(s) understand timezones, use them.
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<h2><a name="s-syncing-time"></a>16.4 Syncing time, rdate and NTP</h2>
|
|
|
|
<p>
|
|
If you have another Unix computer which you know keeps the correct time, with
|
|
root privileges you can set the time with the command <code>rdate</code>. For
|
|
example:
|
|
</p>
|
|
|
|
<pre>
|
|
rdate <var>somehost.domain.com</var>
|
|
</pre>
|
|
|
|
<p>
|
|
Even if you do not have an accurate time source, it is still a good idea to set
|
|
all your computers to the same time, so that you can compare <strong>time
|
|
stamps</strong> between hosts. To keep the clocks syncronized, You can start
|
|
rdate once daily from cron.
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<h3><a name="s16.4.1"></a>16.4.1 Setting time at system boot</h3>
|
|
|
|
<p>
|
|
If the hardware clock does not keep the correct time, it is possible to set the
|
|
correct time when the operating system boots. For this, there must be some
|
|
other host in the LAN where the time can be received. Here is an example:
|
|
</p>
|
|
<ol type="1" start="1" >
|
|
<li>
|
|
<p>
|
|
create the file <code>/etc/init.d/rdate</code>
|
|
</p>
|
|
|
|
<pre>
|
|
$ cat rdate
|
|
#! /bin/sh
|
|
#
|
|
# rdate Execute the rdate command.
|
|
#
|
|
# Version: 1998-11-01 tapio.lehtonen@iki.fi
|
|
#
|
|
|
|
PATH=/sbin:/bin:/usr/sbin:/usr/bin
|
|
HOST=dilbert
|
|
|
|
# Set operating system time from other host in LAN.
|
|
if [ -x /usr/sbin/rdate ]
|
|
then
|
|
/usr/sbin/rdate $HOST
|
|
fi
|
|
</pre>
|
|
</li>
|
|
</ol>
|
|
<ol type="1" start="2" >
|
|
<li>
|
|
<pre>
|
|
chmod a+rx /etc/init.d/rdate
|
|
</pre>
|
|
</li>
|
|
</ol>
|
|
<ol type="1" start="3" >
|
|
<li>
|
|
<p>
|
|
Create a symbolic link to that file in directory <code>/etc/rc2.d</code>
|
|
</p>
|
|
|
|
<pre>
|
|
cd /etc/rc2.d
|
|
ln -s ../init.d/rdate S19rdate
|
|
</pre>
|
|
</li>
|
|
</ol>
|
|
<ol type="1" start="4" >
|
|
<li>
|
|
<p>
|
|
At next reboot, you should see the time being set.
|
|
</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<p>
|
|
Remember to set execute permission to <code>/etc/init.d/rdate</code>. If You
|
|
are wondering what the number S19 above means, read chapter ???. The key is to
|
|
run rdate after netbase which starts networking, and before xntp3 or some other
|
|
process where time is needed starts.
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<h3><a name="s16.4.2"></a>16.4.2 Setting time using NTP</h3>
|
|
|
|
<p>
|
|
If you are connected to the Internet, you can install an NTP client, for
|
|
example <code>ntp</code> or <code>xntp3</code> in Debian version 2.1 and older.
|
|
This uses the Network Time Protocol RFC 1305 to synchronise clocks to a few
|
|
tens of milliseconds precision. If you <em>need</em> this kind of precision or
|
|
better, see also <a href="#s-radio-clocks">Radio clocks, Section 16.6</a>.
|
|
</p>
|
|
|
|
<p>
|
|
See the excellent documentation that comes with <code>ntp</code>, in the Debian
|
|
package <code>ntp-doc</code>. It is very thorough and thus long. If you think
|
|
reading documents is a waste of time, just ask your Internet Service Provider
|
|
or system administrator for NTP server names, or look up the nearest one in
|
|
"List of Public NTP Servers" in
|
|
http://www.eecis.udel.edu/~mills/ntp/servers.html . If you start using an NTP
|
|
server, it is usually polite to notify the server's administrator of the fact.
|
|
</p>
|
|
|
|
<p>
|
|
<em>Do not configure your system to query level 1 NTP servers! If you think
|
|
you need to do this, you are almost certainly wrong!</em>
|
|
</p>
|
|
|
|
<p>
|
|
Once you know an NTP server, edit the file <code>/etc/ntp.conf</code> to add at
|
|
least one server line. Here is an example:
|
|
</p>
|
|
|
|
<pre>
|
|
# /etc/ntp.conf, configuration for xntpd
|
|
|
|
logfile /var/log/xntpd
|
|
driftfile /var/lib/ntp/ntp.drift
|
|
statsdir /var/log/ntpstats/
|
|
|
|
statistics loopstats peerstats clockstats
|
|
filegen loopstats file loopstats type day enable
|
|
filegen peerstats file peerstats type day enable
|
|
filegen clockstats file clockstats type day enable
|
|
|
|
server ntp.somedomain.something
|
|
server ntp.something.else
|
|
</pre>
|
|
|
|
<p>
|
|
Note, that I changed the actual server name in the above example, to prevent
|
|
all Debian GNU/Linux users from blindly using that one server. Everything else
|
|
except the server lines was there after <code>xntp3</code> installation.
|
|
</p>
|
|
|
|
<p>
|
|
If you do not have a permanent Internet connection, then running NTP client is
|
|
not a good solution. NTP client syncronizes relatively often, and needs the
|
|
Internet connection to be always on. If you have a dial up Internet
|
|
connection, you can run the command <code>ntpdate</code> (also in
|
|
<code>ntp</code> package) to syncronize each time you connect.
|
|
</p>
|
|
|
|
<p>
|
|
Another possibility is to set cron to run <code>ntpdate</code> once daily, this
|
|
gives good accuracy for most uses. The following is an example script that can
|
|
be started from cron and runs <code>ntpdate</code>. This scripts assumes the
|
|
<code>/etc/ntp.conf</code> is correctly set up, since it gets the server names
|
|
from that file.
|
|
</p>
|
|
|
|
<pre>
|
|
dilbert# cat /etc/cron.nightly/ntpdate
|
|
#!/bin/sh
|
|
#
|
|
# Last modification: Sat Aug 8 05:27:07 EEST 1998
|
|
# ntpdate cron nightly
|
|
|
|
NTPDATE=/usr/sbin/ntpdate
|
|
LOGFILE=/var/log/xntpd
|
|
NTPCONFFILE=/etc/ntp.conf
|
|
NTPSERVERS=
|
|
GREP=/usr/bin/grep
|
|
CUT=/usr/bin/cut
|
|
|
|
if [ -f $NTPCONFFILE ] ; then
|
|
echo "===========================" >> $LOGFILE
|
|
echo "<<< `date` " >> $LOGFILE
|
|
for i in `grep ^server $NTPCONFFILE | $CUT --fields 2 --delimiter \ `
|
|
do
|
|
NTPSERVERS="$NTPSERVERS $i"
|
|
done
|
|
$NTPDATE $NTPSERVERS >> $LOGFILE
|
|
###echo $NTPDATE $NTPSERVERS $LOGFILE
|
|
echo ">>> `date` " >> $LOGFILE
|
|
fi
|
|
|
|
exit 0
|
|
dilbert#
|
|
</pre>
|
|
|
|
<hr>
|
|
|
|
<h3><a name="s16.4.3"></a>16.4.3 Other methods</h3>
|
|
|
|
<p>
|
|
Debian GNU/Linux has also the command <code>netdate</code>, see man page
|
|
<code>netdate(8L)</code> for more info. It uses the protocol defined in RFC
|
|
868.
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<h2><a name="s16.5"></a>16.5 Setting up an NTP server</h2>
|
|
|
|
<p>
|
|
If you have several hosts that you want to synchronise, you should not let them
|
|
all separately synchronise to an outside NTP server. This puts a load on the
|
|
NTP server, and if it is a public and free service, the people there may start
|
|
to dislike you! At least ask if it is OK to sync all of your machines there.
|
|
</p>
|
|
|
|
<p>
|
|
A better way is to set up one of your hosts as an NTP server, sync that to the
|
|
outside NTP server and the rest of your hosts to your own NTP server. The
|
|
<code>ntp</code> package provides the server component as well, so you just
|
|
need to configure it. This is not particularly difficult either, but you
|
|
should read the documentation and understand the peer concept and stratum
|
|
hierarchy.
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<h2><a name="s-radio-clocks"></a>16.6 Radio clocks</h2>
|
|
|
|
<p>
|
|
If you want better accuracy or cannot synchronise with an NTP server in the
|
|
public Internet, you can purchase a radio clock. These get the time from time
|
|
servers that use a very accurate clock, and broadcast time signals using radio
|
|
waves.
|
|
</p>
|
|
|
|
<p>
|
|
There are radio clocks that need a ground based transmitter near enough to get
|
|
the signal. If you get one of these, make sure you can receive the signal on
|
|
the location where you plan to use it. The transmitters are ground based, so
|
|
they don't work accross the globe.
|
|
</p>
|
|
|
|
<p>
|
|
Another kind of radio clock uses a Global Positioning System GPS receiver. GPS
|
|
satellites circle the globe in low earth orbits, and there should always be at
|
|
least four above the horizon. They are mainly used for navigation, but the
|
|
principle they work on is based on sending time signals. For time
|
|
synchronisation it is enough to get the signal from one satellite, but usually
|
|
it is necessary to install the GPS antenna outdoors to get good reception.
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<h2><a name="s16.7"></a>16.7 Timestamps</h2>
|
|
|
|
<p>
|
|
Timestamps in files are in UTC. The command <code>ls -l</code> shows file
|
|
timestamps in local time using the Timezone in effect. Because timestamps are
|
|
in UTC, timestamps can be compared between separate computers. This can lead
|
|
to problems if the clocks are not syncronized.
|
|
</p>
|
|
|
|
<p>
|
|
Consider this situation: You log in host B, which NFS loads your home directory
|
|
from NFS server host A. You edit some file, save it and start
|
|
<code>make</code>. If the clocks in hosts A and B are not syncronized,
|
|
<code>make</code> may complain that the file modification time is in the
|
|
future, or not compile the file because the object is newer.
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<h2><a name="s16.8"></a>16.8 Time in cron</h2>
|
|
|
|
<p>
|
|
The times in cron are local times. This means, that if you configure cron to
|
|
start some program at 7 in the morning, it is 7 in the morning local time as
|
|
determined by the system Timezone.
|
|
</p>
|
|
|
|
<p>
|
|
This causes headaches, if the system Timezone is not the same you have set for
|
|
yourself using the TZ enviroment variable, or you have two host in different
|
|
Timezones that need to start someting at the same time on both hosts.
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<p>
|
|
[ <a href="ch-sysadmin-config.html">previous</a> ]
|
|
[ <a href="index.html#contents">Contents</a> ]
|
|
[ <a href="ch-sysadmin-intro.html">1</a> ]
|
|
[ <a href="ch-sysadmin-overview.html">2</a> ]
|
|
[ <a href="ch-sysadmin-files.html">3</a> ]
|
|
[ <a href="ch4.html">4</a> ]
|
|
[ <a href="ch-sysadmin-directories.html">5</a> ]
|
|
[ <a href="ch-sysadmin-filesystems.html">6</a> ]
|
|
[ <a href="ch-sysadmin-booting.html">7</a> ]
|
|
[ <a href="ch-sysadmin-users.html">8</a> ]
|
|
[ <a href="ch-sysadmin-sessions.html">9</a> ]
|
|
[ <a href="ch-sysadmin-printing.html">10</a> ]
|
|
[ <a href="ch-sysadmin-accounting.html">11</a> ]
|
|
[ <a href="ch-sysadmin-backup.html">12</a> ]
|
|
[ <a href="ch-sysadmin-X.html">13</a> ]
|
|
[ <a href="ch-sysadmin-security.html">14</a> ]
|
|
[ <a href="ch-sysadmin-config.html">15</a> ]
|
|
[ 16 ]
|
|
[ <a href="ch-sysadmin-localisation.html">17</a> ]
|
|
[ <a href="ch-sysadmin-index.html">18</a> ]
|
|
[ <a href="ch-sysadmin-localisation.html">next</a> ]
|
|
</p>
|
|
|
|
<hr>
|
|
|
|
<p>
|
|
Debian GNU/Linux System Administrator's Manual (Obsolete Documentation)
|
|
</p>
|
|
|
|
<address>
|
|
This manual is OBSOLETE and DEPRECATED since 2006, 29 Dezember 2009. Instead see http://www.de.debian.org/doc/user-manuals#quick-reference.<br>
|
|
<br>
|
|
Ardo van Rangelrooij <code><a href="mailto:ardo.van.rangelrooij@tip.nl">ardo.van.rangelrooij@tip.nl</a></code><br>
|
|
Tapio Lehtonen <code><a href="mailto:Tapio.Lehtonen@IKI.FI">Tapio.Lehtonen@IKI.FI</a></code><br>
|
|
Oliver Elphick - Previous maintainer<br>
|
|
<br>
|
|
</address>
|
|
<hr>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|