Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What if BUG appears in the localtime_r run of centos7?

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

What if BUG appears in the localtime_r run of centos7? In response to this problem, the editor summed up the article today, hoping to help more friends who want to solve this problem to find a more simple and easy way.

Localtime_r has a BUG in centos7 (redhat7). The specific process is as follows:

The step1 background process starts.

Step2 users modify the time zone.

The step3 backward process does not update the time zone when it uses localtime_r to fetch time. The acquisition time is still the old time. However, localtime uses the new time zone to calculate the time.

After step4 uses the localtime call at this time, localtime_r uses the new time zone to calculate the time.

PS, centos6 does not have this problem.

BUG 2

Centos7.5, the process uses gettimeofday (& tv,&tz); the time zone will not be fetched correctly. Tz.tz_minuteswest is always 0. Before manually using timedatectl set-timezone Asia/Shanghai (time zone parameters are arbitrary), configure the time zone once before it can be normal.

In centos7's system, add a timer to see if the / etc/localtime soft connection file has changed. If there is a change, localtime is called once.

This allows localtime_r to use the new time zone.

This is the end of the method to solve the problem of BUG in the operation of localtime_r. Solving the problem is not just the method analyzed in the article and everyone, but the accuracy of the method analyzed in this article is indisputable. If you like this article, you might as well share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report