https://blog.csdn.net/rareli/article/details/78851397
Esxi不支持修改时区,但是可以使用ESX或者Centos 6/7的localtime文件进行替换以实现时区修改,问题是,重启后文件会被还原。
详细的纠结过程就不说了,终级解决方案如下(给公司写的,现分享出来):
大概思路是:将centos 6(也可能是redhat,也可能是ubuntu)中/usr/share/zoneinfo/Asia/Shanghai文件(在exsi6.7下zoneinfo/Asia/Shanghai文件不一定存在)(如果是它国时区,请自行替换base64内容)进行base64编码,然后使用shell脚本生成python脚本并执行后进行解码。
那么,如果没有Shanghai文件,从哪里获得,链接在下面:
https://www.chenghuajie.cn/usr/uploads/2018/10/887936927.gz
最好保存下来,这个链接不知道哪天就没了。
将以下shell脚本代码段添加到ESXI的/etc/rc.local.d/local.sh文件中,贴在exit 0之前重启便可。
如果想立刻生效,只需将以下代码段贴到任意位置的将建shell脚本文件中(如:/tmp/set_time_zone.sh)后执行此脚本就行。
#Add script to /etc/rc.local.d/local.sh before ‘exit 0’ in VMWare esxi 5.x/6.x
#以下请设置临时文件路径/Set temp script file path
temp_shell_script_path="/tmp/set_timezone.sh"
#以下请设置localtime路径(如需测试请填写其它自定义路径,默认请填写/etc/localtime),Set localtime file path,e.g. “/etc/localtime”
sys_localtime_path="/etc/localtime"
#In python echo base64,because VMWare ESxi have no command “base64”.
echo “#Beijing Joycore Technology Co., Ltd. " > $temp_shell_script_path
echo “#Set Timezone For VMWARE-ESXI 5.x/6.x” >> $temp_shell_script_path
echo “import base64” >> $temp_shell_script_path
echo “str_timezone = ‘VFppZjIAAAAAAAAAAAAAAAAAAAAAAAADAAAAAwAAAAAAAAARAAAAAwAAAAyw/pqgyFwBgMj6J3DJ’” >> $temp_shell_script_path
echo “str_timezone = str_timezone + ‘1Q6Aytta8B66NgAfaX9wIH5ogCFJYXAiXkqAIylDcCRHZwAlEl/wJidJACbyQfAoBysAKNIj8AIB’” >> $temp_shell_script_path
echo “str_timezone = str_timezone + ‘AgECAQIBAgECAQIBAgECAABx4AAAAAB+kAEEAABwgAAITE1UAENEVABDU1QAAAAAAAAAVFppZjIA’” >> $temp_shell_script_path
echo “str_timezone = str_timezone + ‘AAAAAAAAAAAAAAAAAAAAAAADAAAAAwAAAAAAAAARAAAAAwAAAAz/sP6aoP/IXAGA’” >> $temp_shell_script_path
echo “str_timezone = str_timezone + ‘/8j6J3D/ydUOgP/K21rwAAAAAB66NgAAAAAAH2l/cAAAAAAgfmiAAAAAACFJYXAAAAAA’” >> $temp_shell_script_path
echo “str_timezone = str_timezone + ‘Il5KgAAAAAAjKUNwAAAAACRHZwAAAAAAJRJf8AAAAAAmJ0kAAAAAACbyQfAAAAAAKAcrAAAAAAAo’” >> $temp_shell_script_path
echo “str_timezone = str_timezone + ‘0iPwAgECAQIBAgECAQIBAgECAQIAAHHgAAAAAH6QAQQAAHCAAAhMTVQAQ0RUAENTVAAAAAAAAAAK’” >> $temp_shell_script_path
echo “str_timezone = str_timezone + ‘Q1NULTgK’” >> $temp_shell_script_path
echo “#Print file /usr/share/zoneinfo/Asia/Shanghai source from Centos 6.x” >>
t
e
m
p
s
h
e
l
l
s
c
r
i
p
t
p
a
t
h
e
c
h
o
"
f
o
u
t
=
o
p
e
n
(
′
temp_shell_script_path echo "fout = open('
tempshellscriptpathecho"fout=open(′sys_localtime_path’, ‘wb’)” >> $temp_shell_script_path
echo “fout.write(base64.b64decode(str_timezone))” >> $temp_shell_script_path
echo “fout.close” >> $temp_shell_script_path
#delete old file who names localtime
rm -f $sys_localtime_path
#rebuild new file with localtime
python $temp_shell_script_path
#delete temp python script
rm -f $temp_shell_script_path
echo “JOYCORE:TIMEZONE UPDATED … OK”
————————————————
原文链接:https://blog.csdn.net/rareli/article/details/78851397
、