个人工具

“UbuntuHelp:UbuntuTime”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
(新页面: {{From|https://help.ubuntu.com/community/UbuntuTime}} {{Languages|UbuntuHelp:UbuntuTime}} == Ubuntu Time Management == This page gives useful information about the way that Ubuntu manage...)
 
第1行: 第1行:
 
{{From|https://help.ubuntu.com/community/UbuntuTime}}
 
{{From|https://help.ubuntu.com/community/UbuntuTime}}
 
{{Languages|UbuntuHelp:UbuntuTime}}
 
{{Languages|UbuntuHelp:UbuntuTime}}
 
 
== Ubuntu Time Management ==
 
== Ubuntu Time Management ==
 
This page gives useful information about the way that Ubuntu manages time by changing the timezone, setting up synchronization using Network Time Protocol(NTP), and adjusting servers.
 
This page gives useful information about the way that Ubuntu manages time by changing the timezone, setting up synchronization using Network Time Protocol(NTP), and adjusting servers.
 
 
=== Changing the Time Zone ===
 
=== Changing the Time Zone ===
 
This section shows you how to accomplish this task using either the Graphical User Interface(GUI) or by using the command line(terminal).
 
This section shows you how to accomplish this task using either the Graphical User Interface(GUI) or by using the command line(terminal).
 
 
==== Using the GUI ====
 
==== Using the GUI ====
 
Perhaps the most user friendly way to change the time zone of your Ubuntu system is to use the Graphical User Interface(GUI).
 
Perhaps the most user friendly way to change the time zone of your Ubuntu system is to use the Graphical User Interface(GUI).
第18行: 第15行:
 
0. Select the closest city then choose '''Close'''
 
0. Select the closest city then choose '''Close'''
 
https://help.ubuntu.com/community/UbuntuTime?action=AttachFile&do=get&target=ntpgui8.png
 
https://help.ubuntu.com/community/UbuntuTime?action=AttachFile&do=get&target=ntpgui8.png
 
 
==== Using the Command Line(terminal) ====
 
==== Using the Command Line(terminal) ====
 
Using the command line, you can use <code><nowiki>tzconfig</nowiki></code>. The man page of this tool has a good explanation on how to set time on a Linux system, how it differs from other systems, and what you have to consider when using computers in a network.
 
Using the command line, you can use <code><nowiki>tzconfig</nowiki></code>. The man page of this tool has a good explanation on how to set time on a Linux system, how it differs from other systems, and what you have to consider when using computers in a network.
 
 
0. Open a terminal window by going to Applications>Accessories>Terminal
 
0. Open a terminal window by going to Applications>Accessories>Terminal
 
0. `tzconfig`
 
0. `tzconfig`
 
0. Follow the directions in the terminal.
 
0. Follow the directions in the terminal.
 
 
=== Time Synchronization using NTP ===
 
=== Time Synchronization using NTP ===
 
This page describes methods for automatically keeping your computer's time accurate. This is extremely useful for servers, and is also recommended for desktop machines.
 
This page describes methods for automatically keeping your computer's time accurate. This is extremely useful for servers, and is also recommended for desktop machines.
 
 
Network Time Protocol(NTP) is a TCP/IP protocol for synchronizing time over a network connection. Basically a client requests the current time from a server, and then uses the servers response to set its own clock.
 
Network Time Protocol(NTP) is a TCP/IP protocol for synchronizing time over a network connection. Basically a client requests the current time from a server, and then uses the servers response to set its own clock.
 
 
Beyond this simple description, there is a lot of complexity. There are multiple tiers of NTP servers, with the tier one NTP servers connected to atomic clocks (often via GPS), and tier two and three servers spreading the load of actually handling requests across the internet. The client software is a lot more complex than you might think as it has to factor communication delays, and adjust the time in a way that does not affect the other processes that run on the system. Luckily all that complexity is hidden from the user.
 
Beyond this simple description, there is a lot of complexity. There are multiple tiers of NTP servers, with the tier one NTP servers connected to atomic clocks (often via GPS), and tier two and three servers spreading the load of actually handling requests across the internet. The client software is a lot more complex than you might think as it has to factor communication delays, and adjust the time in a way that does not affect the other processes that run on the system. Luckily all that complexity is hidden from the user.
 
 
==== Using the GUI ====
 
==== Using the GUI ====
 
This is how to enable NTP time synchronization using the GUI(Graphical User Interface).
 
This is how to enable NTP time synchronization using the GUI(Graphical User Interface).
第47行: 第38行:
 
0. You are now finished and you can click '''Close''' or you can customize the NTP servers(default is ntp.ubuntu.com) that your computer uses to synchronize with by choosing '''Select Servers'''.
 
0. You are now finished and you can click '''Close''' or you can customize the NTP servers(default is ntp.ubuntu.com) that your computer uses to synchronize with by choosing '''Select Servers'''.
 
https://help.ubuntu.com/community/UbuntuTime?action=AttachFile&do=get&target=ntpgui5.png
 
https://help.ubuntu.com/community/UbuntuTime?action=AttachFile&do=get&target=ntpgui5.png
 
 
 
 
==== Command Line ntpdate ====
 
==== Command Line ntpdate ====
 
Ubuntu comes with ntpdate as standard, and will run it once at boot time to set up your time according to Ubuntu's NTP server. However, a system's clock is likely to drift considerably between reboots if the time between reboots is long. In that case it makes sense to correct the time occasionally. The easiest way to do this is to get cron to run it every day. With your favorite editor, create a file `/etc/cron.daily/ntpdate` containing:
 
Ubuntu comes with ntpdate as standard, and will run it once at boot time to set up your time according to Ubuntu's NTP server. However, a system's clock is likely to drift considerably between reboots if the time between reboots is long. In that case it makes sense to correct the time occasionally. The easiest way to do this is to get cron to run it every day. With your favorite editor, create a file `/etc/cron.daily/ntpdate` containing:
第55行: 第43行:
 
sudo ntpdate ntp.ubuntu.com
 
sudo ntpdate ntp.ubuntu.com
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Make sure that you make this new file executable:
 
Make sure that you make this new file executable:
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo chmod 755 /etc/cron.daily/ntpdate
 
sudo chmod 755 /etc/cron.daily/ntpdate
 
</nowiki></pre>
 
</nowiki></pre>
 
 
==== Command Line ntpd ====
 
==== Command Line ntpd ====
 
ntpdate is a bit of a blunt instrument as it can only adjust the time once a day in one big correction. The ntp daemon ntpd is far more subtle as it calculates the drift of your system clock and continuously adjusts it in small increments. Using ntpd there are no large corrections that could lead to inconsistent logs for instance. The cost is a little processing power and memory, but for a modern system this is negligible.
 
ntpdate is a bit of a blunt instrument as it can only adjust the time once a day in one big correction. The ntp daemon ntpd is far more subtle as it calculates the drift of your system clock and continuously adjusts it in small increments. Using ntpd there are no large corrections that could lead to inconsistent logs for instance. The cost is a little processing power and memory, but for a modern system this is negligible.
 
 
To set up ntpd pre Ubuntu 7.04:
 
To set up ntpd pre Ubuntu 7.04:
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo apt-get install ntp-simple
 
sudo apt-get install ntp-simple
 
</nowiki></pre>
 
</nowiki></pre>
 
 
To setup ntpd in versions of Ubuntu 7.04 and higher
 
To setup ntpd in versions of Ubuntu 7.04 and higher
 
<pre><nowiki>
 
<pre><nowiki>
 
sudo apt-get install ntp
 
sudo apt-get install ntp
 
</nowiki></pre>
 
</nowiki></pre>
 
 
 
=== Changing NTP Time Servers ===
 
=== Changing NTP Time Servers ===
 
In both cases above, your system will use Ubuntu's NTP server at `ntp.ubuntu.com` by default. This is OK, but you might want to use several servers to increase accuracy and resilience, and you may want to use time servers that are geographically closer to you.
 
In both cases above, your system will use Ubuntu's NTP server at `ntp.ubuntu.com` by default. This is OK, but you might want to use several servers to increase accuracy and resilience, and you may want to use time servers that are geographically closer to you.
 
 
==== Using the GUI ====
 
==== Using the GUI ====
 
0. Right click on the clock in the top right hand corner of your desktop and select Adjust Date & Time
 
0. Right click on the clock in the top right hand corner of your desktop and select Adjust Date & Time
第87行: 第68行:
 
0. Enable the box next to your choice of server(s) or add your own.
 
0. Enable the box next to your choice of server(s) or add your own.
 
https://help.ubuntu.com/community/UbuntuTime?action=AttachFile&do=get&target=ntpgui6.png
 
https://help.ubuntu.com/community/UbuntuTime?action=AttachFile&do=get&target=ntpgui6.png
 
 
 
==== ntpdate ====
 
==== ntpdate ====
 
Change the contents of `/etc/cron.daily/ntpdate` to:
 
Change the contents of `/etc/cron.daily/ntpdate` to:
第101行: 第80行:
 
</nowiki></pre>
 
</nowiki></pre>
 
You may notice `pool.ntp.org` in the examples above. This is a really good idea which uses round-robin DNS to return an NTP server from a pool, spreading the load between several different servers. Even better, they have pools for different regions - I am in New Zealand, so I use `nz.pool.ntp.org` instead of `pool.ntp.org`. Look at http://www.pool.ntp.org/ for more details.
 
You may notice `pool.ntp.org` in the examples above. This is a really good idea which uses round-robin DNS to return an NTP server from a pool, spreading the load between several different servers. Even better, they have pools for different regions - I am in New Zealand, so I use `nz.pool.ntp.org` instead of `pool.ntp.org`. Look at http://www.pool.ntp.org/ for more details.
 
 
You can also Google for NTP servers in your region, and add these to your configuration. To test that a server works, just type `sudo ntpdate ntp.server.name` and see what happens.
 
You can also Google for NTP servers in your region, and add these to your configuration. To test that a server works, just type `sudo ntpdate ntp.server.name` and see what happens.
 
 
=== Multiple Boot Systems Time Conflicts ===
 
=== Multiple Boot Systems Time Conflicts ===
 
Operating systems store and retrieve the time in the hardware clock located on your motherboard so that it can keep track of the time even when the system does not have power. Most current operating systems(Linux/Unix/Mac) store the time on the hardware clock as UTC/GMT, though some systems(MSWindows) store the time on the hardware clock as the 'local' time.  This causes problems in a dual boot system as both systems view the hardware clock differently.
 
Operating systems store and retrieve the time in the hardware clock located on your motherboard so that it can keep track of the time even when the system does not have power. Most current operating systems(Linux/Unix/Mac) store the time on the hardware clock as UTC/GMT, though some systems(MSWindows) store the time on the hardware clock as the 'local' time.  This causes problems in a dual boot system as both systems view the hardware clock differently.
 
 
It is usually better to have the hardware clock as UTC because then you don't need to change the hardware clock when Daylight Savings Time(DST) begins or ends as UTC does not have DST.
 
It is usually better to have the hardware clock as UTC because then you don't need to change the hardware clock when Daylight Savings Time(DST) begins or ends as UTC does not have DST.
 
 
==== Make Windows use UTC ====
 
==== Make Windows use UTC ====
 
To make MS Windows calculate the time from the hardware clock as UTC.
 
To make MS Windows calculate the time from the hardware clock as UTC.
第114行: 第89行:
 
<pre><nowiki>
 
<pre><nowiki>
 
Windows Registry Editor Version 5.00
 
Windows Registry Editor Version 5.00
 
 
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation]
 
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation]
 
"RealTimeIsUniversal"=dword:00000001
 
"RealTimeIsUniversal"=dword:00000001
 
</nowiki></pre>
 
</nowiki></pre>
 
 
==== Make Linux use 'Local' time ====
 
==== Make Linux use 'Local' time ====
 
To make your Ubuntu system read the hardware clock as 'local'
 
To make your Ubuntu system read the hardware clock as 'local'
第127行: 第100行:
 
UTC=no
 
UTC=no
 
</nowiki></pre>
 
</nowiki></pre>
 
 
 
----
 
----
 
[[category:CategoryDocumentation]]
 
[[category:CategoryDocumentation]]
  
 
[[category:UbuntuHelp]]
 
[[category:UbuntuHelp]]

2007年11月30日 (五) 21:57的版本

Ubuntu Time Management

This page gives useful information about the way that Ubuntu manages time by changing the timezone, setting up synchronization using Network Time Protocol(NTP), and adjusting servers.

Changing the Time Zone

This section shows you how to accomplish this task using either the Graphical User Interface(GUI) or by using the command line(terminal).

Using the GUI

Perhaps the most user friendly way to change the time zone of your Ubuntu system is to use the Graphical User Interface(GUI). 0. Right-click on your clock, and choose Adjust Time & Date, it will open up the following window: UbuntuTime?action=AttachFile&do=get&target=ntpgui0.png 0. Click on the currently selected time zone to bring up the selection map. UbuntuTime?action=AttachFile&do=get&target=ntpgui5.png 0. Click in the general area of your location on the time zone map, the map will zoom in. UbuntuTime?action=AttachFile&do=get&target=ntpgui7.png 0. Select the closest city then choose Close UbuntuTime?action=AttachFile&do=get&target=ntpgui8.png

Using the Command Line(terminal)

Using the command line, you can use tzconfig. The man page of this tool has a good explanation on how to set time on a Linux system, how it differs from other systems, and what you have to consider when using computers in a network. 0. Open a terminal window by going to Applications>Accessories>Terminal 0. `tzconfig` 0. Follow the directions in the terminal.

Time Synchronization using NTP

This page describes methods for automatically keeping your computer's time accurate. This is extremely useful for servers, and is also recommended for desktop machines. Network Time Protocol(NTP) is a TCP/IP protocol for synchronizing time over a network connection. Basically a client requests the current time from a server, and then uses the servers response to set its own clock. Beyond this simple description, there is a lot of complexity. There are multiple tiers of NTP servers, with the tier one NTP servers connected to atomic clocks (often via GPS), and tier two and three servers spreading the load of actually handling requests across the internet. The client software is a lot more complex than you might think as it has to factor communication delays, and adjust the time in a way that does not affect the other processes that run on the system. Luckily all that complexity is hidden from the user.

Using the GUI

This is how to enable NTP time synchronization using the GUI(Graphical User Interface). 0. Right click on the clock in the top right hand corner of your desktop and select Adjust Date & Time UbuntuTime?action=AttachFile&do=get&target=ntpgui0.png 0. You may have to enter your password to continue. UbuntuTime?action=AttachFile&do=get&target=ntpgui1.png 0. Select the configuration option Keep synchronized with Internet servers UbuntuTime?action=AttachFile&do=get&target=ntpgui2.png 0. You may get a dialog box informing you that NTP support has to be installed. UbuntuTime?action=AttachFile&do=get&target=ntpgui3.png 0. After selecting Install NTP Support it will download the needed files. UbuntuTime?action=AttachFile&do=get&target=ntpgui4.png 0. You are now finished and you can click Close or you can customize the NTP servers(default is ntp.ubuntu.com) that your computer uses to synchronize with by choosing Select Servers. UbuntuTime?action=AttachFile&do=get&target=ntpgui5.png

Command Line ntpdate

Ubuntu comes with ntpdate as standard, and will run it once at boot time to set up your time according to Ubuntu's NTP server. However, a system's clock is likely to drift considerably between reboots if the time between reboots is long. In that case it makes sense to correct the time occasionally. The easiest way to do this is to get cron to run it every day. With your favorite editor, create a file `/etc/cron.daily/ntpdate` containing:

sudo ntpdate ntp.ubuntu.com

Make sure that you make this new file executable:

sudo chmod 755 /etc/cron.daily/ntpdate

Command Line ntpd

ntpdate is a bit of a blunt instrument as it can only adjust the time once a day in one big correction. The ntp daemon ntpd is far more subtle as it calculates the drift of your system clock and continuously adjusts it in small increments. Using ntpd there are no large corrections that could lead to inconsistent logs for instance. The cost is a little processing power and memory, but for a modern system this is negligible. To set up ntpd pre Ubuntu 7.04:

sudo apt-get install ntp-simple

To setup ntpd in versions of Ubuntu 7.04 and higher

sudo apt-get install ntp

Changing NTP Time Servers

In both cases above, your system will use Ubuntu's NTP server at `ntp.ubuntu.com` by default. This is OK, but you might want to use several servers to increase accuracy and resilience, and you may want to use time servers that are geographically closer to you.

Using the GUI

0. Right click on the clock in the top right hand corner of your desktop and select Adjust Date & Time UbuntuTime?action=AttachFile&do=get&target=ntpgui0.png 0. You may have to enter your password to continue. UbuntuTime?action=AttachFile&do=get&target=ntpgui1.png 0. Select Configure Servers UbuntuTime?action=AttachFile&do=get&target=ntpgui5.png 0. Enable the box next to your choice of server(s) or add your own. UbuntuTime?action=AttachFile&do=get&target=ntpgui6.png

ntpdate

Change the contents of `/etc/cron.daily/ntpdate` to:

ntpdate ntp.ubuntu.com pool.ntp.org

ntpd

Change the contents of `/etc/ntp.conf` to include additional server lines:

ntp.ubuntu.com
server pool.ntp.org

You may notice `pool.ntp.org` in the examples above. This is a really good idea which uses round-robin DNS to return an NTP server from a pool, spreading the load between several different servers. Even better, they have pools for different regions - I am in New Zealand, so I use `nz.pool.ntp.org` instead of `pool.ntp.org`. Look at http://www.pool.ntp.org/ for more details. You can also Google for NTP servers in your region, and add these to your configuration. To test that a server works, just type `sudo ntpdate ntp.server.name` and see what happens.

Multiple Boot Systems Time Conflicts

Operating systems store and retrieve the time in the hardware clock located on your motherboard so that it can keep track of the time even when the system does not have power. Most current operating systems(Linux/Unix/Mac) store the time on the hardware clock as UTC/GMT, though some systems(MSWindows) store the time on the hardware clock as the 'local' time. This causes problems in a dual boot system as both systems view the hardware clock differently. It is usually better to have the hardware clock as UTC because then you don't need to change the hardware clock when Daylight Savings Time(DST) begins or ends as UTC does not have DST.

Make Windows use UTC

To make MS Windows calculate the time from the hardware clock as UTC. Create a file named https://help.ubuntu.com/community/UbuntuTime?action=AttachFile&do=get&target=WindowsTimeFixUTC.reg with the following contents and then double click on it to merge the contents with the registry:

Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation]
"RealTimeIsUniversal"=dword:00000001

Make Linux use 'Local' time

To make your Ubuntu system read the hardware clock as 'local' 0. edit /etc/default/rcS 0. add or change the following section

# Set UTC=yes if your system clock is set to UTC (GMT)
UTC=no