Updating time on linux

Updating time on linux

This tutorial describes how to update the system date and time on an Oracle Linux system from the command line. It also describes how to configure the chrony time synchronization service. This tutorial is targeted at Oracle Linux 8 users, but the timedatectl command can be used on other systems where systemd is installed, such as Oracle Linux 7.

Background

Many Oracle Linux systems are installed without a desktop environment. However, multiple ways using command lines are available to configure base system settings, such as the system date and time.

On Oracle Linux systems, use the timedatectl command to set the system date and time. The command updates the real time clock (RTC), also known as the hardware clock, as well as the system clock that is maintained by the system kernel.

To ensure that your system time is accurate, enable the chrony NTP service and configure it to access configured NTP servers.

What Do You Need?

  • Any Oracle Linux system that uses systemd
  • Network access to an NTP server (optional)

Check the current configuration

To check the current date and time configuration for a system, run the timedatectl command without any parameters, for example:

The system displays information about the current date and time configuration.

Note that if the NTP service is set to active, your system’s date and time are automatically synchronized with the configured NTP server. Therefore, you would be unable to directly modify the date or time on your system.

Set the system time zone

Set the system time zone by running the following command:

Substitute region/city with the value for your global region and the closest major city to your location.

To obtain a listing of available time zones, run this command:

As an option, use grep city to narrow your search. Use the underscore (_) for cities with compound names. For example, for a setting that uses Pacific Daylight Time (PDT), you might make the following search:

Based on the search results, you would use America/Los_Angeles for your region/city. Note that other cities can also be valid for a PDT setting, such as America/Vancouver.

Set the system date and time

If you do not have an NTP service configured and enabled, you can manually set the system date and time running the following command:

Substitute YYYY-MM-DD hh:mm:ss with the respective values for the current year, month, day, hour, minute and second.

The command also works if you specify only a date change or only a time change. Both commands are valid:

The date and time values are updated for both the RTC and the system clock.

Configure the system to synchronize with a network time service

Oracle Linux 8 ships with the chrony network time service by default. If the service is not available on the system, install the package first. Otherwise, the commands in these examples fail.

To enable and run the NTP service, run the following command:

The date and time values are automatically synchronized with the configured NTP servers.

To change the NTP servers with which your system is synchronized, edit the /etc/chrony.conf file.

See the chrony.conf(5) manual page for more information about configuring this service.

Читайте также:  Как разметить диск под линукс минт

Video Demonstration

The video demonstration and tutorial provided at https://www.youtube.com/watch?v=q8VlYiF5sx8 may also be useful if you need more information on configuring the date and time from the command line interface.

Want to Learn More?

Oracle Linux: Update the System Date and Time From the Command Line Interface

Copyright © 2021, OracleВ and/orВ itsВ affiliates.В

This tutorial describes how to update the system date and time on an Oracle Linux system from the command line and describes how to configure the chrony time synchronization service.

This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited.

The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing.

If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, then the following notice is applicable:

U.S. GOVERNMENT END USERS: Oracle programs (including any operating system, integrated software, any programs embedded, installed or activated on delivered hardware, and modifications of such programs) and Oracle computer documentation or other Oracle data delivered to or accessed by U.S. Government end users are «commercial computer software» or «commercial computer software documentation» pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use, reproduction, duplication, release, display, disclosure, modification, preparation of derivative works, and/or adaptation of i) Oracle programs (including any operating system, integrated software, any programs embedded, installed or activated on delivered hardware, and modifications of such programs), ii) Oracle computer documentation and/or iii) other Oracle data, is subject to the rights and limitations specified in the license contained in the applicable contract. The terms governing the U.S. Government’s use of Oracle cloud services are defined by the applicable contract for such services. No other rights are granted to the U.S. Government.

This software or hardware is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware in dangerous applications.

Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.

Intel and Intel Inside are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Epyc, and the AMD logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group.

This software or hardware and documentation may provide access to or information about content, products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services unless otherwise set forth in an applicable agreement between you and Oracle. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services, except as set forth in an applicable agreement between you and Oracle.

Читайте также:  Что делать если ноутбук не выключается после завершения работы windows 10

Источник

Updating time on linux

This tutorial describes how to update the system date and time on an Oracle Linux system from the command line. It also describes how to configure the chrony time synchronization service. This tutorial is targeted at Oracle Linux 8 users, but the timedatectl command can be used on other systems where systemd is installed, such as Oracle Linux 7.

Background

Many Oracle Linux systems are installed without a desktop environment. However, multiple ways using command lines are available to configure base system settings, such as the system date and time.

On Oracle Linux systems, use the timedatectl command to set the system date and time. The command updates the real time clock (RTC), also known as the hardware clock, as well as the system clock that is maintained by the system kernel.

To ensure that your system time is accurate, enable the chrony NTP service and configure it to access configured NTP servers.

What Do You Need?

  • Any Oracle Linux system that uses systemd
  • Network access to an NTP server (optional)

Check the current configuration

To check the current date and time configuration for a system, run the timedatectl command without any parameters, for example:

The system displays information about the current date and time configuration.

Note that if the NTP service is set to active, your system’s date and time are automatically synchronized with the configured NTP server. Therefore, you would be unable to directly modify the date or time on your system.

Set the system time zone

Set the system time zone by running the following command:

Substitute region/city with the value for your global region and the closest major city to your location.

To obtain a listing of available time zones, run this command:

As an option, use grep city to narrow your search. Use the underscore (_) for cities with compound names. For example, for a setting that uses Pacific Daylight Time (PDT), you might make the following search:

Based on the search results, you would use America/Los_Angeles for your region/city. Note that other cities can also be valid for a PDT setting, such as America/Vancouver.

Set the system date and time

If you do not have an NTP service configured and enabled, you can manually set the system date and time running the following command:

Substitute YYYY-MM-DD hh:mm:ss with the respective values for the current year, month, day, hour, minute and second.

The command also works if you specify only a date change or only a time change. Both commands are valid:

The date and time values are updated for both the RTC and the system clock.

Configure the system to synchronize with a network time service

Oracle Linux 8 ships with the chrony network time service by default. If the service is not available on the system, install the package first. Otherwise, the commands in these examples fail.

To enable and run the NTP service, run the following command:

The date and time values are automatically synchronized with the configured NTP servers.

To change the NTP servers with which your system is synchronized, edit the /etc/chrony.conf file.

See the chrony.conf(5) manual page for more information about configuring this service.

Video Demonstration

The video demonstration and tutorial provided at https://www.youtube.com/watch?v=q8VlYiF5sx8 may also be useful if you need more information on configuring the date and time from the command line interface.

Want to Learn More?

Oracle Linux: Update the System Date and Time From the Command Line Interface

Читайте также:  Скрипт для настройки сети windows 10

Copyright © 2021, OracleВ and/orВ itsВ affiliates.В

This tutorial describes how to update the system date and time on an Oracle Linux system from the command line and describes how to configure the chrony time synchronization service.

This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited.

The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing.

If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, then the following notice is applicable:

U.S. GOVERNMENT END USERS: Oracle programs (including any operating system, integrated software, any programs embedded, installed or activated on delivered hardware, and modifications of such programs) and Oracle computer documentation or other Oracle data delivered to or accessed by U.S. Government end users are «commercial computer software» or «commercial computer software documentation» pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use, reproduction, duplication, release, display, disclosure, modification, preparation of derivative works, and/or adaptation of i) Oracle programs (including any operating system, integrated software, any programs embedded, installed or activated on delivered hardware, and modifications of such programs), ii) Oracle computer documentation and/or iii) other Oracle data, is subject to the rights and limitations specified in the license contained in the applicable contract. The terms governing the U.S. Government’s use of Oracle cloud services are defined by the applicable contract for such services. No other rights are granted to the U.S. Government.

This software or hardware is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware in dangerous applications.

Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.

Intel and Intel Inside are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Epyc, and the AMD logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark of The Open Group.

This software or hardware and documentation may provide access to or information about content, products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services unless otherwise set forth in an applicable agreement between you and Oracle. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services, except as set forth in an applicable agreement between you and Oracle.

Источник

Оцените статью