zoukankan      html  css  js  c++  java
  • Linux命令-更新系统时间和硬件时间

    查看系统时间和时区:

    date 查看系统时间
    date -R 查看时区

    修改时区:

    tzselect  修改时区 

     或

    cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 上海时间

    rm /etc/localtime ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 上海时间
    ln -s /usr/share/zoneinfo/America/Los_Angeles /etc/localtime 洛杉矶时间

    修改时钟文件:

    /etc/sysconfig/clock

    修改为:

    ZONE="Asia/Shanghai"
    UTC=false
    ARC=false

    修改系统时间:

    date  查看当前系统时间
    yum install -y ntpdate 安装ntpdate程序
    ntpdate time.windows.com  从互联网更新系统时间
    ntpdate cn.pool.ntp.org 从互联网更新系统时间 date 再次查看当前系统时间

    如果ntpdate time.windows.com出错了.

    lsof -i:123 查看123端口使用情况
    kill -9 1469 杀死进程
    ntpdate time.windows.com 同步时间

    查看linux lsof详解

    同步BIOS时钟,强制把系统时间写入CMOS

    clock --show   查看硬件时间
    clock -w       强制把系统时间写入CMOS
    clock --show   查看硬件时间
    reboot 重起机器

    重新启动系统,硬件时间会读取系统时间,实现同步;但是在不重新启动的时候,需要用hwclock或clock命令实现同步。

    硬件时钟与系统时钟同步:hwclock --hctosys (hc代表硬件时间,sys代表系统时间)或者 clock --hctosys
    系统时钟和硬件时钟同步:hwclock --systohc或者 clock --systohc

    让linux自动从time.windows.com自动同步时间

    vi /etc/crontab

    加上一句自动同步时间:

    00 0 1 * * ntpdate -s time.windows.com  --每天凌晨1点
    * */1 * * * ntpdate -s time.windows.com --每一个小时
    * */1 * * * ntpdate -s cn.pool.ntp.org
  • 相关阅读:
    马拦过河卒
    最小生成树 kruskal算法
    链表,关键是结构体的快排
    Shortest Prefixes 字典树
    串的匹配
    A Beautiful Meadow
    Tiling
    邻接矩阵的宽度遍历
    邻接矩阵的深度遍历
    Form1.frm
  • 原文地址:https://www.cnblogs.com/qiyebao/p/4424550.html
Copyright © 2011-2022 走看看