要用root权限才可以修改
目录
查询当前系统时间
1 2 3 4 |
[dreamren@dreamren ~]$ su root 密码: [root@dreamren dreamren]# date 2019年 05月 07日 星期二 20:44:30 CST |
查询硬件时间
1 2 |
[root@dreamren dreamren]# hwclock --show 2019年05月07日 星期二 20时47分28秒 -0.823366 秒 |
假如上面的系统时间和硬件时间都不对,那我们进行时间的修改
更新系统年月日
1 2 3 4 5 6 7 8 9 10 11 |
[root@dreamren dreamren]# timedatectl set-time 2019-05-07 //更新系统时分秒 [root@dreamren dreamren]# timedatectl set-time 21:25:08 //更新时区(亚洲-中国-上海) [root@dreamren dreamren]# timedatectl set-timezone Asia/Shanghai //将硬件时钟调整为与系统时钟一致 [root@dreamren dreamren]# timedatectl set-local-rtc 1 //或使用下面的语句也可以 [root@dreamren dreamren]# hwclock --systohc --localtime //将日期写入CMOS [root@dreamren dreamren]# clock –w |
可能在更新时间时出现不能更改的错误提示,这时我们把时间同步关闭,再去修改即可;
1 2 3 |
[root@dreamren dreamren]# timedatectl set-time 2019-05-07 Failed to set time: Automatic time synchronization is enabled [root@dreamren dreamren]# timedatectl set-ntp no |
评论(0)