温馨提示:本文最后更新于
2025-06-02 14:26:16
,某些文章具有时效性,若有错误或已失效,请在下方留言!
AI智能摘要
文章介绍了如何在Linux系统中查询和修改系统时间及硬件时间。用户需要以root权限登录,使用date和hwclock命令查看系统时间和硬件时间。若时间错误,可通过timedatectl命令设置日期、时间和时区,并将系统时间同步到硬件时钟。修改失败时,可能需要先关闭时间同步功能(timedatectl set-ntp no)。
— 此摘要由AI分析文章内容生成,仅供参考。
要用root权限才可以修改
查询当前系统时间
[dreamren@dreamren ~]$ su root
密码:
[root@dreamren dreamren]# date 2019年 05月 07日 星期二 20:44:30 CST
查询硬件时间
[root@dreamren dreamren]# hwclock --show
2019年05月07日 星期二 20时47分28秒 -0.823366 秒
假如上面的系统时间和硬件时间都不对,那我们进行时间的修改
更新系统年月日
[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
可能在更新时间时出现不能更改的错误提示,这时我们把时间同步关闭,再去修改即可;
[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
OK,完活!!
本站资源均为网友推荐收集整理而来,请勿商业运营,仅供学习和研究,请在下载后24小时内删除!!
© 版权声明
THE END
暂无评论内容