|
Size: 1297
Comment:
|
Size: 1038
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 1: | Line 1: |
| = System Date = | = Linux Clock = |
| Line 3: | Line 3: |
| Linux distros often come with a wonky system date--both in the past (i.e., when the image was generated) and in a different timezone (usually GMT). This can cause significant issues on web servers, as signed SSL certificates are only valid within a date range. | On Linux, the '''clock''' generally uses UTC time with a timezone offset in software, as opposed to local time. |
| Line 5: | Line 5: |
| Set the timezone before trying to set the date. | <<TableOfContents>> ---- == Date and Time == Use '''`date(1)`''' as the root user to set the current date and time. {{{ # January 1st, 2001 at 12:30 sudo date 0101011230 }}} Use '''`hwclock(1)`''' or [[TimeDateCtl|timedatectl(1)]] to check the CMOS clock. |
| Line 13: | Line 28: |
| The easy-to-use tool for setting timezones is `timedatectl`. | The configured timezone is set in `/etc/localtime`. By standard convention, this should be a symbolic link to a pre-prepared file, typically under `/usr/share/zoneinfo`. To check the current configuration, try: |
| Line 16: | Line 33: |
| timedatectl status # observe current setting timedatectl list-timezones # observe available settings timedatectl set-timezone Zone/SubZone # apply a new setting |
realpath /etc/localtime |
| Line 21: | Line 36: |
| This is just a wrapper around `ln` however. The manual process is: | To change the configuration, try: |
| Line 24: | Line 39: |
| realpath /etc/localtime # observe current setting ls /usr/share/zoneinfo # observe available zones ls /usr/share/zoneinfo/Zone # observe available subzones ln -sf /usr/share/zoneinfo/Zone/SubZone /etc/localtime # apply a new setting |
ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime |
| Line 30: | Line 42: |
| ---- | For `systemd`-capable systems, consider using [[TimeDateCtl#Timezone|timedatectl(1)]]. |
| Line 32: | Line 44: |
== Date == The system date is set using the standard `date` utility, run as the superuser with an argument. |
Some utilities will also respect a `TZ` environment variable. |
| Line 39: | Line 47: |
| sudo date 2001011230 # sets system date to January 1st, 2020 at 12:30 | export TZ=America/New_York date |
Linux Clock
On Linux, the clock generally uses UTC time with a timezone offset in software, as opposed to local time.
Contents
Date and Time
Use date(1) as the root user to set the current date and time.
# January 1st, 2001 at 12:30 sudo date 0101011230
Use hwclock(1) or timedatectl(1) to check the CMOS clock.
Timezone
The configured timezone is set in /etc/localtime. By standard convention, this should be a symbolic link to a pre-prepared file, typically under /usr/share/zoneinfo.
To check the current configuration, try:
realpath /etc/localtime
To change the configuration, try:
ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
For systemd-capable systems, consider using timedatectl(1).
Some utilities will also respect a TZ environment variable.
export TZ=America/New_York date
