Differences between revisions 1 and 3 (spanning 2 versions)
Revision 1 as of 2020-01-22 01:37:58
Size: 1297
Comment:
Revision 3 as of 2020-11-11 15:24:25
Size: 1058
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= System Date = = System Clock in Linux =
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. The '''system clock''' in Linux generally uses the '''Coordinated Universal Time ''' ('''UTC''') standard, as opposed to '''localtime'''.
Line 5: 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 13: Line 16:
The easy-to-use tool for setting timezones is `timedatectl`. Use '''`timedatectl(1)`''' to set the local timezone.
Line 16: 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 ZONE/SUBZONE
Line 21: 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 24: Line 27:
realpath /etc/localtime # observe current setting
ls /usr/share/zoneinfo # observe available zones
ls /usr/share/zoneinfo/Zone # observe available subzones
realpath /etc/localtime
ls /usr/share/zoneinfo/*
Line 36: Line 38:
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 39: Line 41:
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.


Timezone

Use timedatectl(1) to set the local timezone.

timedatectl status
timedatectl list-timezones
timedatectl set-timezone ZONE/SUBZONE

timedatectl(1) is a simple utility script; the manual equivalents roughly are...

realpath /etc/localtime
ls /usr/share/zoneinfo/*
ln -sf /usr/share/zoneinfo/Zone/SubZone /etc/localtime   # apply a new setting


Date

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


CategoryRicottone

Linux/Clock (last edited 2023-06-29 17:16:15 by DominicRicottone)