鉴于最近测tbox时间同步,记录上linux 时间相关的。
1、时间同步 命令:
ntpdate cn.pool.ntp.org
cn.pool.ntp.org 是公网环境授时服务器
2、查看当前时间,带时区
date 或者 date -R
date -R
Mon, 16 Mar 2020 18:30:08 +0800
+0800 代表东八区
date
Mon Mar 16 18:30:11 CST 2020
CST 中国标准时间
3、查看硬件时间
hwclock 或者 hwclock --show
hwclock --show
Mon Mar 16 10:36:00 2020 0.000000 seconds
4、修改时间
//以系统时间为基准,修改硬件时间
hwclock --systohc 或者 hwclock -w
//以硬件时间为基准,修改系统时间
hwclock --hctosys 或者 hwclock -s
设置硬件时间
hwclock --set --date “20140225 20:23:00”
修改系统时间
date -s “20140225 20:16:00” #yyyymmdd hh:mm:ss
5、Linux时间与系统时间相差8小时的解决办法
原因是时区不同
在/etc/profile文件中增加一行 export TZ=‘CST-8’
使文件立即生效
source /etc/profile 或者 . /etc/profile
TZ