LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS
User Name
Password
CentOS This forum is for the discussion of CentOS Linux. Note: This forum does not have any official participation.

Notices


Reply
  Search this Thread
Old 04-02-2022, 06:58 PM   #1
SPiKeGoD
LQ Newbie
 
Registered: Apr 2022
Posts: 15

Rep: Reputation: 0
Centos 7 - I can't fix the datetime


I have tried to fix the time with:

date -s "04/03/2022 01:06:31"

or

timedatectl set-time 01:06:31

But it is impossible, it shows always 8 hours more as local time

[root@localhost ~]# timedatectl status Local time: Sun 2022-04-03 09:06:31 CEST Universal time: Sun 2022-04-03 07:06:31 UTC RTC time: Sun 2022-04-03 07:06:31 Time zone: Europe/Madrid (CEST, +0200) NTP enabled: yes NTP synchronized: no RTC in local TZ: no DST active: yes Last DST change: DST began at Sun 2022-03-27 01:59:59 CET Sun 2022-03-27 03:00:00 CEST Next DST change: DST ends (the clock jumps one hour backwards) at Sun 2022-10-30 02:59:59 CEST Sun 2022-10-30 02:00:00 CET

[root@localhost ~]# date date Sun Apr 3 09:06:32 CEST 2022

The timezone "Europe/Madrid" is OK

Any idea to fix it?

Thanks you very much in advance
 
Old 04-02-2022, 08:05 PM   #2
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Ubuntu MATE, Mageia, and whatever VMs I happen to be playing with
Posts: 19,358
Blog Entries: 28

Rep: Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148Reputation: 6148
Is it possible that the hardware clock is off? See man hwclock.
 
Old 04-03-2022, 01:20 AM   #3
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
More importantly, what exactly do those commands return?
Please show us the commands themselves & all their output, in CODE tgas (see my signature).

Quote:
Originally Posted by SPiKeGoD View Post
I have tried to fix the time with:

date -s "04/03/2022 01:06:31"

or

timedatectl set-time 01:06:31

But it is impossible, it shows always 8 hours more as local time

[root@localhost ~]# timedatectl status Local time: Sun 2022-04-03 09:06:31 CEST Universal time: Sun 2022-04-03 07:06:31 UTC RTC time: Sun 2022-04-03 07:06:31 Time zone: Europe/Madrid (CEST, +0200) NTP enabled: yes NTP synchronized: no RTC in local TZ: no DST active: yes Last DST change: DST began at Sun 2022-03-27 01:59:59 CET Sun 2022-03-27 03:00:00 CEST Next DST change: DST ends (the clock jumps one hour backwards) at Sun 2022-10-30 02:59:59 CEST Sun 2022-10-30 02:00:00 CET

[root@localhost ~]# date date Sun Apr 3 09:06:32 CEST 2022

The timezone "Europe/Madrid" is OK

Any idea to fix it?

Thanks you very much in advance
 
Old 04-03-2022, 06:02 AM   #4
SPiKeGoD
LQ Newbie
 
Registered: Apr 2022
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by frankbell View Post
Is it possible that the hardware clock is off? See man hwclock.
Now is 13:02

[root@localhost ~]# hwclock
Sun 03 Apr 2022 09:01:37 PM CEST -0.459538 seconds
 
Old 04-03-2022, 06:07 AM   #5
SPiKeGoD
LQ Newbie
 
Registered: Apr 2022
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by ondoho View Post
More importantly, what exactly do those commands return?
Please show us the commands themselves & all their output, in CODE tgas (see my signature).
Code:
[root@localhost ~]# date -s "04/03/2022 13:04:31"
Sun Apr  3 13:04:31 CEST 2022

Code:
[root@localhost ~]# timedatectl set-time 13:05:30
Failed to set time: Automatic time synchronization is enabled

Code:
[root@localhost ~]# timedatectl
      Local time: Sun 2022-04-03 21:05:15 CEST
  Universal time: Sun 2022-04-03 19:05:15 UTC
        RTC time: Sun 2022-04-03 19:04:55
       Time zone: Europe/Madrid (CEST, +0200)
     NTP enabled: yes
NTP synchronized: no
 RTC in local TZ: no
      DST active: yes
 Last DST change: DST began at
                  Sun 2022-03-27 01:59:59 CET
                  Sun 2022-03-27 03:00:00 CEST
 Next DST change: DST ends (the clock jumps one hour backwards) at
                  Sun 2022-10-30 02:59:59 CEST
                  Sun 2022-10-30 02:00:00 CET
You have new mail in /var/spool/mail/root
 
Old 04-03-2022, 06:20 AM   #6
SPiKeGoD
LQ Newbie
 
Registered: Apr 2022
Posts: 15

Original Poster
Rep: Reputation: 0
The time on the BIOS had 6 more hours, i have changed the time to 13:16 (local time here, Spain), but the time now has 2 more hours:

Code:
[root@localhost ~]# timedatectl
      Local time: Sun 2022-04-03 15:17:29 CEST
  Universal time: Sun 2022-04-03 13:17:29 UTC
        RTC time: Sun 2022-04-03 13:17:29
       Time zone: Europe/Madrid (CEST, +0200)
     NTP enabled: yes
NTP synchronized: no
 RTC in local TZ: no
      DST active: yes
 Last DST change: DST began at
                  Sun 2022-03-27 01:59:59 CET
                  Sun 2022-03-27 03:00:00 CEST
 Next DST change: DST ends (the clock jumps one hour backwards) at
                  Sun 2022-10-30 02:59:59 CEST
                  Sun 2022-10-30 02:00:00 CET
Code:
[root@localhost ~]# date
Sun Apr  3 15:18:58 CEST 2022
The right time is 13:18 not 15:18
 
Old 04-04-2022, 07:04 AM   #7
SPiKeGoD
LQ Newbie
 
Registered: Apr 2022
Posts: 15

Original Poster
Rep: Reputation: 0
New tests:

Code:
[root@localhost ~]# hwclock
Mon 04 Apr 2022 01:31:35 PM CEST  -0.250859 seconds
Code:
[root@localhost ~]# date
Mon Apr  4 20:31:30 CEST 2022
[root@localhost ~]# timedatectl
      Local time: Mon 2022-04-04 20:31:34 CEST
  Universal time: Mon 2022-04-04 18:31:34 UTC
        RTC time: Mon 2022-04-04 11:31:43
       Time zone: Europe/Madrid (CEST, +0200)
     NTP enabled: no
NTP synchronized: no
 RTC in local TZ: no
      DST active: yes
 Last DST change: DST began at
                  Sun 2022-03-27 01:59:59 CET
                  Sun 2022-03-27 03:00:00 CEST
 Next DST change: DST ends (the clock jumps one hour backwards) at
                  Sun 2022-10-30 02:59:59 CEST
                  Sun 2022-10-30 02:00:00 CET
[root@localhost ~]#
The time is OK on hwclock but it's wrong on timedatectl and date

The timezone is OK

Any idea?
 
Old 04-04-2022, 08:36 AM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,759

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
Most systems have two clocks i.e. the hardware/BIOS clock and the system clock.

The hardware clock is only used at boot time to sync the system clock. It is a simple integrated circuit clock without any reference. Its either set to local or UTC time and the reference configured in the /etc/adjtime file. The timedatectl shows the reference as RTC in local TZ: yes or no. Since your system is no the hardware clock should be set to UTC.


The system clock is basically a counter that gets incremented by some timer. Its reference is always UTC with zero being 00:00:00 UTC, 1 January 1970.

The timezone setting is used to show the date in local time although many desktops have their own timezone setting.

There are several time sync clients and CentOS uses chrony by default.

systemctl status chronyd

To see how it well it is working

chronyc sources
 
Old 04-04-2022, 09:53 AM   #9
SPiKeGoD
LQ Newbie
 
Registered: Apr 2022
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by michaelk View Post
Most systems have two clocks i.e. the hardware/BIOS clock and the system clock.

The hardware clock is only used at boot time to sync the system clock. It is a simple integrated circuit clock without any reference. Its either set to local or UTC time and the reference configured in the /etc/adjtime file. The timedatectl shows the reference as RTC in local TZ: yes or no. Since your system is no the hardware clock should be set to UTC.


The system clock is basically a counter that gets incremented by some timer. Its reference is always UTC with zero being 00:00:00 UTC, 1 January 1970.

The timezone setting is used to show the date in local time although many desktops have their own timezone setting.

There are several time sync clients and CentOS uses chrony by default.

systemctl status chronyd

To see how it well it is working

chronyc sources
First of all, thank you very much for answering my post!

This is the output:

Code:
[root@localhost ~]# systemctl status chronyd
● chronyd.service - NTP client/server
   Loaded: loaded (/usr/lib/systemd/system/chronyd.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:chronyd(8)
           man:chrony.conf(5)
 
Old 04-04-2022, 09:56 AM   #10
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,759

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
Try restarting it.

systemctl restart chronyd
 
Old 04-04-2022, 09:58 AM   #11
SPiKeGoD
LQ Newbie
 
Registered: Apr 2022
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by michaelk View Post
Try restarting it.

systemctl restart chronyd
The output:

Code:
[root@localhost ~]# systemctl restart chronyd
[root@localhost ~]# systemctl status chronyd
● chronyd.service - NTP client/server
   Loaded: loaded (/usr/lib/systemd/system/chronyd.service; disabled; vendor preset: enabled)
   Active: active (running) since Mon 2022-04-04 23:58:04 CEST; 4s ago
     Docs: man:chronyd(8)
           man:chrony.conf(5)
  Process: 19241 ExecStartPost=/usr/libexec/chrony-helper update-daemon (code=exited, status=0/SUCCESS)
  Process: 19236 ExecStart=/usr/sbin/chronyd $OPTIONS (code=exited, status=0/SUCCESS)
 Main PID: 19239 (chronyd)
   CGroup: /system.slice/chronyd.service
           └─19239 /usr/sbin/chronyd

Apr 04 23:58:04 localhost.localdomain chronyd[19239]: chronyd version 3.4 starting (+CMDMON +NTP +REFCLOCK +RTC +PRIVDROP +SCFILTER +SIGND +ASYNCDNS +SECHASH +IPV6 +DEBUG)
Apr 04 23:58:04 localhost.localdomain chronyd[19239]: Frequency -50.659 +/- 2.206 ppm read from /var/lib/chrony/drift
 
Old 04-04-2022, 10:05 AM   #12
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,759

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
Post the output off the command:

chronyc sources
 
Old 04-04-2022, 10:08 AM   #13
SPiKeGoD
LQ Newbie
 
Registered: Apr 2022
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by michaelk View Post
Post the output off the command:

chronyc sources
Here we go

Code:
[root@localhost ~]# chronyc sources
210 Number of sources = 4
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^- joplin.convolute.net.nz       2   6   377    37    -11ms[  -11ms] +/-  173ms
^- gamma.rueckgr.at              2   6   377    38  -1986us[-1986us] +/-   82ms
^* 185.179.104.7                 1   6   377    40   +696us[+1972us] +/-   15ms
^- ns0.luns.net.uk               2   6   377    38  -5042us[-5042us] +/-   56ms
 
Old 04-04-2022, 10:14 AM   #14
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,759

Rep: Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931Reputation: 5931
Code:
MS Name/IP address         Stratum Poll Reach LastRx Last sample
^* 185.179.104.7                 1   6   377    40   +696us[+1972us] +/-   15ms
This is the server you are currently synced to presently. Does the date command show the correct local time?
 
Old 04-04-2022, 10:16 AM   #15
SPiKeGoD
LQ Newbie
 
Registered: Apr 2022
Posts: 15

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by michaelk View Post
Code:
MS Name/IP address         Stratum Poll Reach LastRx Last sample
^* 185.179.104.7                 1   6   377    40   +696us[+1972us] +/-   15ms
This is the server you are currently synced to presently. Does the date command show the correct local time?
No, my local time (Europe/Madrid) is 17:15. The server has other time

Code:
Tue Apr  5 00:08:20 CEST 2022
[root@localhost ~]# date
Tue Apr  5 00:14:43 CEST 2022

[root@localhost ~]# timedatectl
      Local time: Tue 2022-04-05 00:14:45 CEST
  Universal time: Mon 2022-04-04 22:14:45 UTC
        RTC time: Mon 2022-04-04 15:15:43
       Time zone: Europe/Madrid (CEST, +0200)
     NTP enabled: no
NTP synchronized: no
 RTC in local TZ: no
      DST active: yes
 Last DST change: DST began at
                  Sun 2022-03-27 01:59:59 CET
                  Sun 2022-03-27 03:00:00 CEST
 Next DST change: DST ends (the clock jumps one hour backwards) at
                  Sun 2022-10-30 02:59:59 CEST
                  Sun 2022-10-30 02:00:00 CET
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot fix broken package using "sudo apt --fix-broken install" to fix XFCE packages for Zorin OS 16 Core AltFantasy Zorin OS 8 09-25-2021 06:51 AM
Python: datetime.datetime.strptime() trouble PoleStar Programming 4 12-15-2015 06:43 PM
How can I find files in Linux where filename contains datetime format pthakur Linux - Newbie 1 11-05-2015 04:43 AM
html form current datetime meluser Programming 27 04-16-2003 06:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > CentOS

All times are GMT -5. The time now is 06:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration