Linux时间查看与修改
[ 2019/11/28, 后端技术 , 3107阅, 2评 ]

Linux的时间分为System Clock(系统时间)和Real Time Clock (硬件时间,简称RTC)。

系统时间:指当前Linux内核中的时间

硬件时间:主板上有电池供电的时间

date命令

查看系统时间date

只设置日期date -s 11/28/2019,也可写成20191128或2019-11-28,此时时分秒会默认为00:00:00

只设置时间date -s 12:13:14,此时日期不会改变

设置系统日期和时间date -s "11/28/2019 12:13:14"

hwclock/clock命令

查看硬件时间hwclock --showclock --show

设置硬件时间hwclock --set --date="11/28/2019 12:13:14"clock --set --date="11/28/2019 12:13:14"

hc代表硬件时间,sys代表系统时间

将系统时间同步到硬件时间hwclock --systohcclock --systohc

将硬件时间同步到系统时间hwclock --hctosysclock --hctosys

自动同步网络时间

1、安装ntpdate工具yum -y install ntp ntpdate

2、设置系统时间与网络时间同步ntpdate cn.pool.ntp.org

3、将系统时间写入硬件时间hwclock --systohc

4、强制系统时间写入CMOS中防止重启失效hwclock -wclock -w

有朋自远方来...评论一下呗O(∩_∩)O

  • 评论(2)

    [ 回复 ]
    2020-03-16 16:07

    651250447  您好楼主  我有个关于angular的问题想问下您  找不到您联系方式  方便加下我吗

    大强子 博主大人 [ 回复 ]
    2020-03-16 16:12

    @☀:好