We have scripts to reinstall RHEL 5.x to RHEL 7.x and install our application, but I need to update timezone according to old one. So how to restore timezone from RHEL 5.x to RHEL 7.x using /etc/localtime file (We are taking backup) and in command line?

One of the specific environment is Red Hat Enterprise Linux Server release 5.8 (Tikanga) and Red Hat Enterprise Linux Server release 7.5 (Maipo)

  • So pointing localtime to your time zone file in your script doesn’t work? – FrontENG Aug 19 '19 at 9:28
  • @FrontENG : as the servers might be in different timezones, that won't work I guess. – prado Aug 19 '19 at 9:49
  • do you have ansible or some kind of remote management? – FrontENG Aug 19 '19 at 9:57
  • @FrontENG unfortunately no. – prado Aug 19 '19 at 10:04

I figured it out. In RHEL 5.x, there is a file /etc/sysconfig/clock contains the timezone. Using sed in the script to get the timezone from that file worked out. Sample output of this file:



| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.