Slackware: Setting the Clock

Created: 2022-10-02
Updated: 2023-06-29

Set the date and time via a one-time NTP request. This page is current as of Slackware 15.0.

Simple: Just set the clock (sync with NIST)

$ sudo ntpdate time.nist.gov

Thorough: Check hardware clock, set timezone, sync

  1. Select a timezone (or UTC) with timeconfig (this is the same dialog that asks you "HARDWARE CLOCK SET TO UTC?" when you first install Slackware via the standard setup script.)

  2. Get accurate time for your timezone via NTP with ntpdate.

  3. View and set the hardware clock with hwclock.

Here’s what the whole process looks like (clock was exactly four hours off because it was set to UTC time rather than my local timezone (despite showing the -04:00 timezone!)).

~$ hwclock
2022-10-02 14:03:11.391654-04:00

~$ sudo -i
# timeconfig
    +------------+
    | graphical  |
    | TUI dialog |
    | to select  |
    | timezone   |
    +------------+

# ntpdate time.nist.gov

# hwclock --systohc
# hwclock
2022-10-02 10:04:46.990025-04:00
# exit

~$ date
Sun Oct  2 10:04:59 EDT 2022

You can easily examine the Slackware timeconfig script to see what it’s doing since it’s a shell script:

less /usr/sbin/timeconfig

ntpd On boot

Slackware can run the ntpd daemon on boot, but it’s not enabled by default.

First, uncomment the ntp pool servers from the configuration file:

$ sudo vim /etc/ntp.conf

  ...
  # NTP server (list one or more) to synchronize with:
  server 0.pool.ntp.org iburst
  server 1.pool.ntp.org iburst
  server 2.pool.ntp.org iburst
  server 3.pool.ntp.org iburst
  ...

Then enable the existing startup script:

$ sudo chmod +x /etc/rc.d/rc.ntpd

The daemon does all sorts of complicated things to ensure the time gets safely in sync with official Internet time servers.

You can start it immediately without rebooting and check on its progress with:

$ sudo /etc/rc.d/rc.ntpd start

$ ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
==============================================================================
 LOCAL(0)        .LOCL.          10 l 1464   64    0    0.000   +0.000   0.000
+kong.rellim.com 54.165.164.24    2 u   42   64  357   85.214   -1.079  12.090
-skitty.itu.ch   210.65.119.71    2 u   35   64  377  175.363   +4.456   0.417
*edge-iad.txryan 17.253.20.125    2 u   45   64  377   14.859   +0.635   0.748
+ntpool0.603.new 199.102.46.70    2 u   50   64  377   24.542   -0.068   0.338

(ntpq is an interactive NTP query tool with CLI options for viewing NTP data.)