Differences between revisions 1 and 28 (spanning 27 versions)
Revision 1 as of 2005-06-06 17:46:42
Size: 776
Editor: anonymous
Comment:
Revision 28 as of 2019-12-21 01:10:25
Size: 5084
Editor: PaulWise
Comment: less jargony
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
## Auto-converted by kwiki2moinmoin v2005-10-07
To see the time on Debian GNU/Linux, use the command date
#language en
##TRANSLATION HEADER START
~-[[DebianWiki/EditorGuide#translation|Translation(s)]]: English - [[it/DateTime|Italiano]] -~
##TRANSLATION HEADER END
----
Line 4: Line 7:
When setting the time manually, the time string may be confusing. The command date --set 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.
{{{
## If your page gets really long, uncomment this Table of Contents
<<TableOfContents(2)>>

== See the time ==

To see the time on a Debian GNU/Linux system, use the command {{{date}}}, without arguments it will show system time respecting the currently defined [[TimeZoneChanges|timezone]].

To see the time in the UTC timezone, use the command {{{date --utc}}} (or shorthand {{{date -u}}}). See the [[DebianMan:date.1|date manual page]].

== Set the time manually ==

When setting the system time manually using date directly, the required time specification format may be confusing (by [[POSIX]] convention [[http://pubs.opengroup.org/onlinepubs/9699919799/utilities/date.html|has to be MMDDhhmmYYYY]]). However, when using the {{{--set}}} argument date accepts the date and time in many formats. You can read the man page of [[DebianMan:1/date|date]], or use the example below for one possible and very useful format. The --set argument examples below is specified in the [[https://en.wikipedia.org/wiki/ISO_8601|ISO 8601 standard's]] extended format as YYYY-MM-DD for Year-Month-!DayOfMonth, and time of day HH:MM:SS using 24 hour clock. Leading zeros are significant.{{{
Line 10: Line 23:
The above two commands set the date to 2nd November 1998, and time to eight minutes past 9pm. The above two commands set the system date to second of November, 1998, and system time to eight minutes past nine, PM.
<<BR>>
'''Note''', using the date command only sets the runtime ''system time'' (aka. software clock) but has no effect on the underlying ''hardware clock'' (aka. RTC = real time clock). When the system boots, it has no concept of absolute time and will populate the system time with the date and time read from the hardware clock, thus to ensure that the time set using date is kept across reboots it has to be saved to the hardware clock.
Line 12: Line 27:
To see the time in UTC, use command date -u. Most [[DesktopEnvironment|desktop environments]] provide a date/time configuration utility. See also the `time-admin` program in [[DebianPkg:gnome-system-tools]] package.
Line 14: Line 29:
http://www.debian.org/doc/manuals/system-administrator/ch-sysadmin-time.html === Setting the hardware clock ===

To write the current system time to the hardware clock so that it can be recovered on subsequent restarts of the system, correct the system time as above, then use the command {{{hwclock --systohc}}} to save it to hardware (see the [[DebianMan:8/hwclock|hwclock manual page]] for more options).

Modern Debian releases (2.2 and onwards) automatically save the system time to hardware clock on proper shutdowns, and set the system clock from hardware clock when they boot up. This is done by the script /etc/init.d/hwclock.sh.

== Set the time automatically ==

The protocol used to set the time is the Network Time Protocol or NTP. To set the time automatically you need access to an NTP server. Your local network may provide such a server but most people need to access an NTP server via the internet.

On the internet there are time servers that provide the correct time. Your ISP may provide a time service and this would be your closest and probably most accurate source. While there are still many independent NTP servers you can connect to, the best source is [[http://pool.ntp.org]].

=== Installing NTP ===

It's really quite easy on Debian.

 {{{apt-get install ntp}}}

Because the pool is global, you should adjust <<BR>>
 {{{/etc/ntp.conf}}} <<BR>>
to use more
[[http://www.pool.ntp.org/zone/@|local sources]]. Change the <<BR>>
 {{{server pool.ntp.org}}} <<BR>>
line to <<BR>>
 {{{server XX.pool.ntp.org}}} <<BR>>
where XX is your continent or two letter country code. Click on the continent to see the valid country codes. eg CA for Canada etc.

For increased accuracy you would include extra server lines such as
 {{{server 0.XX.pool.ntp.org}}} <<BR>>
 {{{server 1.XX.pool.ntp.org}}} <<BR>>
incrementing the number for each line. Two or three should be all you need.

== Hardware clock and system time when dual booting ==

While Debian prefer to keep the hardware clock in UTC (this prevents the need to change it on daylight savings and timezone changes) other systems (like Windows) by default keeps the hardware clock [[http://superuser.com/questions/185773/does-windows-7-support-utc-as-bios-time|synchronized to local time]]. To keep the hardware clock sane and the time correctly displayed by multiple systems they need to agree on which timezone the hardware clock is kept at.

In Debian the timezone for the hardware clock is configured in the file /etc/adjtime;

 {{{
0.000000 14602224559 0.000000
1460224559
UTC
 }}}

Edit /etc/adjtime, and change "UTC" to "LOCAL" if you want the hardware clock to be kept at local time instead of UTC.
 You need to use sudo or su to edit this file. Any editor will work, but nano or vi is the normal choice.


== External References ==

https://www.debian.org/doc/manuals/system-administrator/ch-sysadmin-time.html

---

CategorySystemAdministration CategoryTime

Translation(s): English - Italiano


See the time

To see the time on a Debian GNU/Linux system, use the command date, without arguments it will show system time respecting the currently defined timezone.

To see the time in the UTC timezone, use the command date --utc (or shorthand date -u). See the date manual page.

Set the time manually

When setting the system time manually using date directly, the required time specification format may be confusing (by POSIX convention has to be MMDDhhmmYYYY). However, when using the --set argument date accepts the date and time in many formats. You can read the man page of date, or use the example below for one possible and very useful format. The --set argument examples below is specified in the ISO 8601 standard's extended format as YYYY-MM-DD for Year-Month-DayOfMonth, and time of day HH:MM:SS using 24 hour clock. Leading zeros are significant.

     date --set 1998-11-02 
     date --set 21:08:00

The above two commands set the system date to second of November, 1998, and system time to eight minutes past nine, PM.
Note, using the date command only sets the runtime system time (aka. software clock) but has no effect on the underlying hardware clock (aka. RTC = real time clock). When the system boots, it has no concept of absolute time and will populate the system time with the date and time read from the hardware clock, thus to ensure that the time set using date is kept across reboots it has to be saved to the hardware clock.

Most desktop environments provide a date/time configuration utility. See also the time-admin program in gnome-system-tools package.

Setting the hardware clock

To write the current system time to the hardware clock so that it can be recovered on subsequent restarts of the system, correct the system time as above, then use the command hwclock --systohc to save it to hardware (see the hwclock manual page for more options).

Modern Debian releases (2.2 and onwards) automatically save the system time to hardware clock on proper shutdowns, and set the system clock from hardware clock when they boot up. This is done by the script /etc/init.d/hwclock.sh.

Set the time automatically

The protocol used to set the time is the Network Time Protocol or NTP. To set the time automatically you need access to an NTP server. Your local network may provide such a server but most people need to access an NTP server via the internet.

On the internet there are time servers that provide the correct time. Your ISP may provide a time service and this would be your closest and probably most accurate source. While there are still many independent NTP servers you can connect to, the best source is http://pool.ntp.org.

Installing NTP

It's really quite easy on Debian.

  • apt-get install ntp

Because the pool is global, you should adjust

  • /etc/ntp.conf

to use more local sources. Change the

  • server pool.ntp.org

line to

  • server XX.pool.ntp.org

where XX is your continent or two letter country code. Click on the continent to see the valid country codes. eg CA for Canada etc.

For increased accuracy you would include extra server lines such as

  • server 0.XX.pool.ntp.org
    server 1.XX.pool.ntp.org

incrementing the number for each line. Two or three should be all you need.

Hardware clock and system time when dual booting

While Debian prefer to keep the hardware clock in UTC (this prevents the need to change it on daylight savings and timezone changes) other systems (like Windows) by default keeps the hardware clock synchronized to local time. To keep the hardware clock sane and the time correctly displayed by multiple systems they need to agree on which timezone the hardware clock is kept at.

In Debian the timezone for the hardware clock is configured in the file /etc/adjtime;

  • 0.000000 14602224559 0.000000
    1460224559
    UTC

Edit /etc/adjtime, and change "UTC" to "LOCAL" if you want the hardware clock to be kept at local time instead of UTC.

  • You need to use sudo or su to edit this file. Any editor will work, but nano or vi is the normal choice.

External References

https://www.debian.org/doc/manuals/system-administrator/ch-sysadmin-time.html

---

CategorySystemAdministration ?CategoryTime