解决无法修改日志时间的问题(Local time zone must be set--see zic manual page 2019 )
程序员文章站
2022-05-22 18:51:33
故障现象 解决方案(失败) 无效,date命令显示正常,但是放在脚本中的date命令依然报错,并且日志时间依然延后8小时 无效 依然没有什么鸟用 最后网上看了一篇文章大概是说可能是升级libc.so.6导致,尝试以下方法总算成功了 解决方案(成功!) ......
故障现象
- 系统日志时间晚了整整8个小时,比如现在是中午12点,日志时间为凌晨4点
- date命令报错(local time zone must be set--see zic manual page)
解决方案(失败)
- 修改/etc/profile
export tz='asia/shanghai'
无效,date命令显示正常,但是放在脚本中的date命令依然报错,并且日志时间依然延后8小时
- tzselect配置
#tzselect please identify a location so that time zone rules can be set correctly. please select a continent or ocean. 1) africa 2) americas 3) antarctica 4) arctic ocean 5) asia 6) atlantic ocean 7) australia 8) europe 9) indian ocean 10) pacific ocean 11) none - i want to specify the time zone using the posix tz format. #? 5 please select a country. 1) afghanistan 18) israel 35) palestine 2) armenia 19) japan 36) philippines 3) azerbaijan 20) jordan 37) qatar 4) bahrain 21) kazakhstan 38) russia 5) bangladesh 22) korea (north) 39) saudi arabia 6) bhutan 23) korea (south) 40) singapore 7) brunei 24) kuwait 41) sri lanka 8) cambodia 25) kyrgyzstan 42) syria 9) china 26) laos 43) * 10) cyprus 27) lebanon 44) tajikistan 11) east timor 28) macau 45) thailand 12) georgia 29) malaysia 46) turkmenistan 13) * 30) * 47) united arab emirates 14) india 31) myanmar (burma) 48) uzbekistan 15) indonesia 32) nepal 49) vietnam 16) iran 33) oman 50) yemen 17) iraq 34) pakistan #? 9 please select one of the following time zone regions. 1) beijing time 2) * time #? 1 the following information has been given: china beijing time therefore tz='asia/shanghai' will be used. local time is now: wed nov 27 15:47:48 cst 2019. universal time is now: wed nov 27 07:47:48 utc 2019. is the above information ok? 1) yes 2) no #? 1 you can make this change permanent for yourself by appending the line tz='asia/shanghai'; export tz to the file '.profile' in your home directory; then log out and log in again. here is that tz value again, this time on standard output so that you can use the /usr/bin/tzselect command in shell scripts: asia/shanghai [root@compute-0-10: 2019年 11月 27日 星期三 07:47:59 local time zone must be set--see zic manual page /root 3] #date 2019年 11月 27日 星期三 07:48:38 local time zone must be set--see zic manual page
无效
- /etc/localtime
rm -f /etc/localtime cp /usr/share/zoneinfo/asia/shanghai /etc/localtime
依然没有什么鸟用
最后网上看了一篇文章大概是说可能是升级libc.so.6
导致,尝试以下方法总算成功了
解决方案(成功!)
#ll /usr/local/glibc-2.14/etc/ 总用量 8 -rw-r--r-- 1 root root 3694 7月 17 09:50 ld.so.cache lrwxrwxrwx 1 root root 25 7月 17 09:50 localtime -> ../share/zoneinfo/factory -rw-r--r-- 1 root root 1615 7月 17 09:50 rpc #cd /usr/local/glibc-2.14/etc/ #rm localtime rm:是否删除符号链接 "localtime"?y #ln -s /usr/local/glibc-2.14/share/zoneinfo/asia/shanghai localtime