Note:

Configure Chrony on Oracle Linux 8

Introduction

The following tutorial provides step-by-step procedures to configure date and time, and enable Chrony.

Objectives

In this lab, you’ll:

What Do You Need?

(Hands-on Lab) Connect to the Compute Instance

Note: This step is specific to the Oracle provided free lab environment.

The Desktop environment will display before the instance(s) are ready. Deployment of this environment can take two to five minutes, depending on the number of resources and provisioning steps needed.

First, to access the lab compute instance(s), connect to the Oracle Cloud Console and copy the compute instance Public IP address.

  1. Sign in to Oracle Cloud Console, and select your Compartment.

  2. Click Instances.

  3. Copy the Public IP to a temporary location (such as a text file) on your computer.

    copy public ip

    To copy, highlight the IP address with the mouse and press Ctrl+C.

  4. Right-click the Virtual Desktop and select Open Terminal Here.

  5. Connect to the instance.

    ssh -i ../.ssh/id_rsa oracle@<IP_ADDRESS_OF_COMPUTE_INSTANCE>
    

    Where <IP_ADDRESS_OF_COMPUTE_INSTANCE> is the IP address copied from the Oracle Cloud Console.

  6. Accept the ECDSA key fingerprint by typing yes at the prompt.

  7. You are now connected to the compute instance for this lab.

If the connection fails with the Permission denied (publickey,gssapi-keyex,gssapi-with-mic) message, wait a bit longer for the provisioning process to complete and try making the ssh connection again.

Configure System Date and Time

In this practice, you use the date, hwclock, and timedatectl utilities to configure and display date and time information.

  1. Open a terminal and connect to your Oracle Linux 8 instance.

  2. Become the root user.

    sudo su -
    
  3. As the root user, run the date command with no arguments to display the current date and time.

    date
    

    date output

    The current date and time displays.

  4. Run the date command with the argument to view the weekday name.

    date +%A
    

    date output

  5. Run the date command with the argument to view the month name.

    date +%B
    

    date output

  6. Use the date command to change the date to another date, for example 14 December, 2021.

    You can substitute any date.

    date +%D -s 2021-12-14
    

    date output

  7. Use the date command to change the date to the correct date, for example 03 February, 2021.

    date +%D -s 2021-02-03
    

    date output

  8. Use the date command to change the time to your current local time.

    For example, 08:57 AM.

    date +%T%p -s 08:57:00AM
    

    date output

  9. Run the hwclock command with no arguments to display the hardware clock’s current date and time.

    hwclock
    

    hwclock output

  10. Use the hwclock command with the –w option to set the hardware clock to the current system time.

    hwclock -w
    
  11. Run the date command and the hwclock command to confirm that the date and time settings are the same.

    date
    hwclock
    

    The variation in seconds is due to the delay between running the two commands.

    date and hwclock output

  12. Run the timedatectl command with no arguments to display the system date and time information.

    timedatectl
    

    timedatectl output

    If the above output shows NTP service: active, disable it as follows and re-check it:

    timedatectl set-ntp 0
    timedatectl
    

    timedatectl output

  13. Use the timedatectl command to change the date to the correct date.

    • Substitute today’s correct date. The example changes the date to 27 January, 2021.
    • Run the timedatectl command afterwards with no arguments to verify that the date changed.

    timedatectl set-time 2021-01-27
    timedatectl
    

    ticedatectl output

  14. Use the timedatectl command to change the time to the correct time.

    • Substitute the current local time. The example changes the time to 09:11:30 AM.
    • Enter the hour using a 24-hour clock.
    • Run the timedatectl command afterwards with no arguments to verify that the time changed.

    timedatectl set-time 09:11:30
    timedatectl
    

    timedatectl output

Configure NTP Using Chrony

In this section, you configure NTP using chrony.

  1. As the root user, use the dnf command to check that chrony is installed.

    dnf list chrony
    

    dnf output

    • If necessary, install chrony using the dnf command.

    dnf install chrony -y
    
  2. Use the systemctl command to check the status the Chrony daemon, chronyd.

    systemctl status chronyd
    
    • Use the systemctl command to start chronyd if necessary.

    systemctl start chronyd
    
  3. Run the chronyc -n tracking command to check Chrony tracking. The “n” option provides numeric host address output.

    • Alternatively, you could run chronyc to display a chronyc> prompt, and then run the tracking command from the chronyc> prompt.
    • Type quit to exit the chroncyc prompt.
    • Sample output is shown.

    chronyc -n tracking
    

    chronyc output

    Key output fields:

    • Reference ID: Refers to the server providing synchronization.
    • Stratum: The distance from a computer attached to a highly accurate reference clock.
    • Ref time: The most recent time Chrony utilized a time measurement from the server providing synchronization (time is UTC).

  4. Run the chronyc -n sources command to show information about chronyd time sources. The “n” option provides numeric host address output.

    • Sample output is shown.

    chronyc -n sources
    

    chrony output

  5. Run the chronyc -n sources command with the “v” option (verbose) to provide column descriptions.

    • Sample output is shown.

    chronyc -n sources -v
    

    chronyc output

    • For more information about Chrony, see the chronyc main page.

  6. Run the chronyc -n sourcestats command.

    • This command provides statistics around calculations for time sources.
    • Sample output is shown.

    chronyc -n sourcestats
    

    chronyc output

  7. Run the command again but include the –v option to obtain column descriptions.

    chronyc -n sourcestats -v
    

    chronyc output

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.