Size: 1339
Comment:
|
Size: 1258
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
## page was renamed from SystemDateSetup = System Date = |
= System Clock in Linux = |
Line 4: | 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. | The '''system clock''' in Linux generally uses the '''Coordinated Universal Time ''' ('''UTC''') standard, as opposed to '''localtime'''. |
Line 6: | Line 5: |
Set the timezone before trying to set the date. | Linux images often come with a wonky clock setting based on when the image was generated. This can cause significant issues on web servers, as signed SSL certificates are only valid within a date range. <<TableOfContents>> |
Line 14: | Line 16: |
The easy-to-use tool for setting timezones is `timedatectl`. | For `systemd`-capable systems, use '''`timedatectl(1)`''' to set the local timezone. Substitute `America/New_York` with your preferred configuration. |
Line 17: | Line 19: |
timedatectl status # observe current setting timedatectl list-timezones # observe available settings timedatectl set-timezone Zone/SubZone # apply a new setting |
timedatectl status timedatectl list-timezones timedatectl set-timezone America/New_York |
Line 22: | Line 24: |
This is just a wrapper around `ln` however. The manual process is: | `timedatectl(1)` is a simple utility script; the manual equivalents roughly are... |
Line 25: | Line 27: |
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 |
realpath /etc/localtime ls /usr/share/zoneinfo/* ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime }}} Some utilities will also respect a `TZ` environment variable. {{{ export TZ=America/New_York date |
Line 35: | Line 43: |
== Date == | == Date and Time == |
Line 37: | Line 45: |
The system date is set using the standard `date` utility, run as the superuser with an argument. | Use '''`date(1)`''' to set the current datetime. Note that `date(1)` must be called by the root user to set a datetime. |
Line 40: | Line 48: |
sudo date 2001011230 # sets system date to January 1st, 2020 at 12:30 | # January 1st, 2020 at 12:30 sudo date 2001011230 |
System Clock in Linux
The system clock in Linux generally uses the Coordinated Universal Time (UTC) standard, as opposed to localtime.
Linux images often come with a wonky clock setting based on when the image was generated. This can cause significant issues on web servers, as signed SSL certificates are only valid within a date range.
Contents
Timezone
For systemd-capable systems, use timedatectl(1) to set the local timezone. Substitute America/New_York with your preferred configuration.
timedatectl status timedatectl list-timezones timedatectl set-timezone America/New_York
timedatectl(1) is a simple utility script; the manual equivalents roughly are...
realpath /etc/localtime ls /usr/share/zoneinfo/* ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime
Some utilities will also respect a TZ environment variable.
export TZ=America/New_York date
Date and Time
Use date(1) to set the current datetime. Note that date(1) must be called by the root user to set a datetime.
# January 1st, 2020 at 12:30 sudo date 2001011230