ESX修改时间时区
Linux 时钟分为系统时钟(System Clock)和硬件(Real Time Clock ,简称RTC )时钟。系统时钟是指当前Linux Kernel中的时钟,而硬件时钟则是主板上由电池供电的时钟,这个硬件时钟可以在BIOS中进行设置。当Linux 启动时,硬件时钟会去读取系统时钟的设置,然后系统时钟就会独立于硬件运作。
Linux中的所有命令(包括函数)都是采用的系统时钟设置。在Linux中,用于时钟查看和设置的命令主要有date、hwclock和clock。其中,clock和hwclock用法相近,只用一个就行,只不过clock命令除了支持x86硬件体系外,还支持Alpha硬件体系。
1、date
查看系统时间
# date
设置系统时间
# date –set “07/07/06 10:19” (月/日/年时:分:秒)
2、hwclock/clock
查看硬件时间
# hwclock –show
或者# clock –show
设置硬件时间
# hwclock –set –date=”07/07/06 10:19” (月/日/年 时:分:秒)
或者# clock –set –date=”07/07/06 10:19” (月/日/年 时:分:秒)
3、硬件时间和系统时间的同步
按照前面的说法,重新启动系统,硬件时间会读取系统时间,实现同步,但是在不重新启动的时候,需要用hwclock或clock命令实现同步。
硬件时钟与系统时钟同步:# hwclock –hctosys(hc代表硬件时间,sys代表系统时间)或者# clock –hctosys
系统时钟和硬件时钟同步:# hwclock –systohc或者# clock –systohc
4、时区的设置
第一种方式
1、用date修改日期时间
#date -s 08/24/2006
#date -s 13:02:00
2、同步BIOS时钟,强制把系统时间写入CMOS
#clock -w
3、查看Bois时间用 #hwclock -r
第二种方式:NTP服务器的设置
- 确认没有运行ntp daemon。
# /etc/init.d/ntpd stop - 在/etc/ntp.conf中写入如下内容:
driftfile /etc/ntp/drift
logfile /var/log/ntp.log
server time.stdtime.gov.tw
注意:如果没有drift或logfile,需要手动创建之,并把权限设为root可读写,其他用户只读 - 用ntpdate手动更新时间:
这是因为当你的系统时间误差很大,有20~30分钟以上时,ntp的更新将非 常慢,而ntpdate的更新一般是很快的。
[root@t-esx01 cron]# esxcfg-firewall –allowOutgoing
# ntpdate time.stdtime.gov.tw
4.启动ntp daemon:
# /etc/init.d/ntpd start
5. 检查ntpd的状态:
[root@t-esx01 cron]# ntpq -p
remote refid st t when poll reach delay offset jitter
==============================================================================
*time.stdtime.go 192.5.41.41 2 u 37 64 37 95.568 7.235 3.634
- 添加ntpd为系统启动服务:
# chkconfig –add ntpd
# chkconfig –level 3 ntpd on
# chkconfig –level 012456 ntpd off
[root@t-esx01 cron]# esxcfg-firewall –blockOutgoing
第三种方式
修改时区:
第1步:.找到相应的时区文件 /usr/share/zoneinfo/Asia/Shanghai
用这个文件替换当前的/etc/localtime文件。
或者找你认为是标准时间的服务器,然后
#scp root@xxx.xxx.xxx.xxx:/etc/localtime /etc/localtime
第2步:修改/etc/sysconfig/clock文件,修改为:
ZONE=”Asia/Shanghai”
UTC=false
ARC=false