ubuntu关闭时间同步与centos更改时间
环境:ubuntu
源于一次项目需要修改系统时间,但是每次修改后又被同步回网络时间,找了好久发现是这个原因:
NTP即Network Time Protocol(网络时间协议),是一个互联网协议,用于同步计算机之间的系统时钟。timedatectl程序可以自动同步Linux系统时钟到使用NTP的远程服务器(大部分linux系统自带ntp服务而不带ntp client,所以纠结了半天找不到为什么都没装NTP每次改了时间又被同步回网络时间去了)。
1、timedatectl命令:
timedate
Local time: 三 -- :: CST
Universal time: 三 -- :: UTC
Timezone: Asia/Chongqing (CST, +)
NTP enabled: no
NTP synchronized: no
RTC in local TZ: no
DST active: n/a
2,开启关闭ntp(这样就不会自动同步时间了)
timedatectl set-ntp true/false
3,更改时间(使用date命令)
date -s '2020-12-12 11:11:00' #将时间更改成2020年12月12号 11点11分
由于工作中较多使用centos,而且时间的一些命令也是我们经常会遇到的,在此记录下,便于以后查询。
ntpdate -u ntp.api.bz
中国国家授时中心:210.72.145.44
NTP服务器(上海) :ntp.api.bz
时间分为系统时间和硬件时间(如果两者时间不一致时,在重新启动系统的时候会读取硬件时间,并将系统时间修改为硬件时间)
系统时间查看
date
硬件时间查看
hwclock/clock
系统时间的修改已经在前面写到了,这里讲讲硬件时间修改
hwclock --set --date="2018-09-08 14:55" #修改硬件时间为2018年9月8号14点55分
系统时间同步硬件时间(以系统时间为准)
hwclock -w
硬件时间同步系统时间(以硬件时间为准)
hwclock -s
时区更改,当我们开了一台vps时,很多时候时区不对,我们需要更改下时区
时区文件是/etc/localtime
[root@vp-n ~]# date
Tue May :: UTC
[root@vp-n ~]# ls -l /etc/localtime
lrwxrwxrwx root root May : /etc/localtime -> ../usr/share/zoneinfo/UTC
更改成北京时间
[root@vp-n ~]# rm -f /etc/localtime
[root@vp-n ~]# ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
[root@vp-n ~]# date
Tue May :: CST
以上就是对于时间的一些基本的记录,便于以后查询。
ubuntu关闭时间同步与centos更改时间的更多相关文章
- CentOS 7 时间, 日期设置 (含时间同步)
from http://blog.itnmg.net/centos-7-time-date/ yum install ntp //安装ntp服务systemctl enable ntpd //开机启动 ...
- CentOS 同步时间
来源:http://www.ctusky.com/16/0497/ 用date查看系统当前时间,date -R 可查看时区. CentOS 同步时间由ntp服务提供,可以用"yum inst ...
- CentOS同步时间
用date查看系统当前时间,date -R 可查看时区. CentOS 同步时间由ntp服务提供,可以用"yum install ntp -y"安装. 装完后运行命令 ntpdat ...
- ubuntu server设置时区和更新时间
ubuntu server设置时区和更新时间 今天测试时,发现时间不对,查了一下时区: data -R 结果时区是:+0000 我需要的是东八区,这儿显示不是,所以需要设置一个时区 一.运行 ...
- .net 更改时间格式
/// <summary> /// 更改时间格式[HH:mm:ss]到[HHmmss] /// </summary> /// <param name="inpu ...
- Centos 修改时间地区及NTP同步北京时间
在我们使用CentOS系统的时候,也许时区经常会出现问题,有时候改完之后还是会出错,下面我们就来学习一种方法来改变这个状况.如果没有安装,而你使用的是 CentOS系统 那使用命令 yum insta ...
- Linux (Redhat / Fedora / CentOS) 更改 hostname 的方式
Linux (Redhat / Fedora / CentOS) 更改 hostname 的方式 [蔡宗融個人網站]https://www.ichiayi.com/wiki/tech/linux_ho ...
- Ubuntu关闭(重启)网络服务命令
Ubuntu关闭网络服务命令: service network-manager stop 重启网络服务命令: service network-manager restart
- Ubuntu关闭进入screensaver模式
/********************************************************************************* * Ubuntu关闭进入scree ...
随机推荐
- R12.1.3 patch9239090
参考文档:Oracle E-Business Suite Release 12.1.3 Readme [ID 1080973.1]1.调整参数_disable_fast_validate=TRUEpg ...
- Concurrent Request:Inactive phase,No Manager status
Symptom 随便submit一个request,发现几乎所有的Concurrent Manager都为No Manager状态,Phase为Inactive. Solution 一个Concurr ...
- [c# 20问] 3.String和string的区别
POINTS string类型为继承自object的sealed类. string类实例用来存储Unicode字符串. string关键字是System.String类的别名,因此既可以定义strin ...
- mysql 按照时间查询
这篇文章转载自http://blog.csdn.net/wangjuan_01/article/details/51726588 今天 select * from 表名 where to_days(时 ...
- (zxing.net)二维码QR Code的简介、实现与解码
一.简介 二维码QR Code(Quick Response Code)是由Denso公司于1994年9月研制的一种矩阵二维码符号,它具有一维条码及其它二维条码所具有的信息容量大.可靠性高.可表示汉字 ...
- Linq与数据库的连接显示查询(一)
使用linq查询sql数据库是首先需要创建一个 linq to sql 类文件 创建linq to sql的步骤: 1在Visual Studio 2015开发环境中建立一个目标框架 Fra ...
- Winform嵌入其它应用程序
Options: using CommandLine; using System; using System.Collections.Generic; using System.Linq; using ...
- ie兼容placeholder效果
转载:http://www.jb51.net/article/56244.htm placeholder是HTML5<input>的属性之一,在不同的浏览器( 支持HTML5的现代浏览器 ...
- qi zi
#include<stdio.h> ]; ][]; int N; typedef struct node{ int x; }node; node dui[]; int se(int a) ...
- 初探APT 攻击
作者:joe 所属团队:Arctic Shell 本文编写参考: https://www.freebuf.com/vuls/175280.html https://www.freebuf. ...