Configure Chrony on Oracle Linux

4
0
Send lab feedback

Configure Chrony on Oracle Linux

Introduction

The following tutorial provides step-by-step procedures to configure date and time, and enable Chrony. This tutorial is targeted at Oracle Linux 8 users, but the commands are also available on other Oracle Linux releases.

Objectives

In this lab, you'll:

  • Configure date and time
  • Enable chrony

What Do You Need?

  • A fully patched Oracle Linux system

Note: When using the free lab environment, see Oracle Linux Lab Basics for connection and other usage instructions.

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 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 .

SSR