RHEL 7 TimeZone lost after reboot

Lucas Rey

New Member
Joined
Jun 18, 2021
Messages
7
Reaction score
2
Credits
52
Hello community, I'm facing a strange behaviour on Red Hat 7.2

Code:
# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.2 (Maipo)

I setup the TimeZone as:
Code:
# timedatectl set-timezone Europe/Rome
# timedatectl
      Local time: Fri 2021-06-18 14:55:27 CEST
  Universal time: Fri 2021-06-18 12:55:27 UTC
        RTC time: Fri 2021-06-18 12:55:27
       Time zone: Europe/Rome (CEST, +0200)
     NTP enabled: yes
NTP synchronized: no
RTC in local TZ: no
      DST active: yes

That's ok. But after reboot I have:
Code:
# timedatectl
      Local time: Fri 2021-06-18 12:59:44 UTC
  Universal time: Fri 2021-06-18 12:59:44 UTC
        RTC time: Fri 2021-06-18 12:59:44
       Time zone: UTC (UTC, +0000)
     NTP enabled: yes
NTP synchronized: no
RTC in local TZ: no
      DST active: n/a

So, TimeZone is lost after reboot. Could someone can drive me since I'm going crazy?
Thank you
Lucas
 


dos2unix

Well-Known Member
Joined
May 3, 2019
Messages
1,923
Reaction score
1,520
Credits
13,252
My first thought is that your NTP server time is wrong.
 
OP
L

Lucas Rey

New Member
Joined
Jun 18, 2021
Messages
7
Reaction score
2
Credits
52
My first thought is that your NTP server time is wrong.
I don't think so, I tried to disable ntpd service and reboot, but still got TZ changed

Code:
timedatectl set-timezone Europe/Rome

After that I have:
Code:
/etc/localtime -> ../usr/share/zoneinfo/Europe/Rome

But after reboot I got:
Code:
etc/localtime -> /usr/share/zoneinfo/UTC
 

f33dm3bits

Gold Member
Gold Supporter
Joined
Dec 11, 2019
Messages
6,261
Reaction score
4,732
Credits
46,000
Try force creating the symlink yourself?
Code:
ln -sf /usr/share/zoneinfo/Europe/Rome /etc/localtime
Maybe the the BIOS/UEFI clock is overriding the OS system time, try this?
Code:
hwclock --systohc
 

f33dm3bits

Gold Member
Gold Supporter
Joined
Dec 11, 2019
Messages
6,261
Reaction score
4,732
Credits
46,000
Just tried setting your timezone on a virtual machine running RHEL7.9 and it stays as configured after a reboot. Is the system a virtual machine or a physical machine?
 
OP
L

Lucas Rey

New Member
Joined
Jun 18, 2021
Messages
7
Reaction score
2
Credits
52
Just tried setting your timezone on a virtual machine running RHEL7.9 and it stays as configured after a reboot. Is the system a virtual machine or a physical machine?
Yes it's a VM running under openstack
 
OP
L

Lucas Rey

New Member
Joined
Jun 18, 2021
Messages
7
Reaction score
2
Credits
52
After some research I found the root cause. It's openstack that for some reason change the TZ at boot time.
 

f33dm3bits

Gold Member
Gold Supporter
Joined
Dec 11, 2019
Messages
6,261
Reaction score
4,732
Credits
46,000
I kind of suspected something like that but hadn't had time to research it. I did look around a bit just now but it looks like there is no way to override it.
 
OP
L

Lucas Rey

New Member
Joined
Jun 18, 2021
Messages
7
Reaction score
2
Credits
52
I spent a day to search on OS if there is something (like a script) who changes the TZ at boot time, nothing found. I got a confirmation when I cloned the whole system (using rear - relax and recover) and restored on my proxmox environment. The TZ stays there also after several reboot, so the stupid openstack (I hate openstack, but this is another story) changes it during OS boot.

There is a cool workaround for now (until I'll contact the company department who handles openstack server).

Code:
rm /etc/localtime
cp /usr/share/zoneinfo/Europe/Rome /etc/localtime
chattr +i /etc/localtime

So, remove the symlink, copy the TZ and then make it immutable with the related flags. In this way no one can modify it, neither root. It works perfect! :)
 

f33dm3bits

Gold Member
Gold Supporter
Joined
Dec 11, 2019
Messages
6,261
Reaction score
4,732
Credits
46,000
I did try to do that on the symlink but that didn't work like you discovered yourself. I didn't think of removing the symlink and then making the file immutable, it must be Sunday :)
 
OP
L

Lucas Rey

New Member
Joined
Jun 18, 2021
Messages
7
Reaction score
2
Credits
52
Good Sunday! :)
To be honest, I had too some problem setting the flag to symlink. The idea to remove symlink and copy the TZ comes from another community's user. Anyway, it works, so it's ok for now.
 

Members online


Top