zoukankan      html  css  js  c++  java
  • Linux 修改时区和时间

    时区文件

    CentOS 和 Ubuntu 的时区文件是 /etc/localtime , 但是在 CentOS7 以后 localtime 以及变成了一个链接文件 :

    # ll /etc/localtime 
    lrwxrwxrwx. 1 root root 38 Mar 13  2017 /etc/localtime -> ../usr/share/zoneinfo/America/New_York
    
    •  

    修改时区

    CentOS6 , Ubuntu16 修改方法 :

    # cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
    
    • CentOS7 , RHEL7 , Scientific Linux 7 , Oracle Linux 7 :

    最好的方法是使用 timedatectl 命令 :

    # timedatectl set-timezone Asia/Shanghai    #其他时区以此类推
    
    •  

    或者直接手动创建软链接 :

    # ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
    
    •  

    查看时间

    # date
    Wed Aug 15 10:03:44 CST 2018
    
    • 修改时间

    将系统日期设定成 2009年11月3日下午5点55分55秒 :

    # date -s "11/03/2009 17:55:55"
    
    •  

    将系统时间设定成 下午5点55分55秒 :

    # date -s 17:55:55
    
    •  

    查看硬件时间 (BIOS的) :

    # hwclock -r
    
    •  

    将当前时间和日期写入 BIOS , 避免重启后失效 :

    # hwclock -w
    
    •  

    同步时间

    yum install ntpdate

    # ntpdate -u ntp.api.bz

    赞赏码

    非学,无以致疑;非问,无以广识

  • 相关阅读:
    LVM
    Linux 压缩归档
    <基础> PHP 字符串操作
    <基础> PHP 数组操作
    PHP 文件操作类(转载)
    Linux 磁盘管理(分区、创建文件系统、挂载)
    文件系统(File System)
    Linux 硬链接、软链接
    Django基础一
    数据库约束
  • 原文地址:https://www.cnblogs.com/lxwphp/p/15452730.html
Copyright © 2011-2022 走看看