在linux中时间分为硬件时间 和 系统时间, hwclock --show ,即可查看硬件时间,
设置硬件时间 sudo hwclock --set --date="08/24/15 16:47"
将硬件时间(hc)同步到系统 (sys) sudo hwclock --hctosys
也可以设置系统时间的时区, 配置地方 /etc/localtime
设置一台同步时间的服务器 (IP地址为 200.4.0.40 )
1. vi /etc/ntp.conf
server 127.127.1.0 # local clock
2. /etc/init.d/ntpd start #启动时间服务器
3. 查看 ntpq -p
设置需要同步时间的机器
1. 修改 /etc/ntp.conf,如下:
# Undisciplined Local Clock. This is a fake driver intended for backup
# and when no outside source of synchronized time is available.
server 200.4.0.40 # local clock 时间同步服务器A机
fudge 200.4.0.40 stratum 10
2. service ntpd stop
3. 同步时间 sudo ntpdate -d 200.4.0.40
设置别名,显示自定义的格式
alias date='date +%Y-%m-%d" "%H:%M:%S'