当前位置: 移动技术网 > 网络运营>服务器>Linux > CentOS7修改服务器系统时间的方法

CentOS7修改服务器系统时间的方法

2019年06月04日  | 移动技术网网络运营  | 我要评论

未知何故,服务器上的系统时间不对,比实际的utc快了将近63分钟。在涉及本地文件与远程服务器文件的时间戳校验时,容易产生混淆。

这里把系统时间更正的过程记录如下。

参考资料:

在centos 7里面有一个命令timedatectl可以帮助我们修改服务器的时区。

1. 查看服务器里的时间设置 timedatectl ,它等同于 timedatectl status :

$ timedatectl
local time: mon 2016-08-29 16:20:35 cst
universal time: mon 2016-08-29 08:20:35 utc
rtc time: mon 2016-08-29 08:18:07
time zone: asia/shanghai (cst, +0800)
ntp enabled: yes
ntp synchronized: no
rtc in local tz: no
dst active: n/a

2. 了解 timedatectl 命令的各个参数:

$ timedatectl -h
timedatectl [options...] command ...
query or change system time and date settings.
-h --help show this help message
--version show package version
--no-pager do not pipe output into a pager
--no-ask-password do not prompt for password
-h --host=[user@]host operate on remote host
-m --machine=container operate on local container
--adjust-system-clock adjust system clock when changing local rtc mode
commands:
status show current time settings
set-time time set system time
set-timezone zone set system time zone
list-timezones show known time zones
set-local-rtc bool control whether rtc is in local time
set-ntp bool control whether ntp is enabled

3. 设置时间

$ sudo timedatectl set-time 15:26:58$ timedatectl
local time: mon 2016-08-29 15:27:00 cst
universal time: mon 2016-08-29 07:27:00 utc
rtc time: mon 2016-08-29 07:27:00
time zone: asia/shanghai (cst, +0800)
ntp enabled: no
ntp synchronized: no
rtc in local tz: no
dst active: n/a

ps:下面看下centos修改服务器系统时间

linux安装完毕后,一般都是国外的世界,一点都不方便设置任务,或者导致网站获取本地的时间错乱,所以就需要把服务器的时间改为和本地时间一致,也就是换成中国的时间。

第一条指令:date –s '2016-10-31 10:10:10'

第二条指令:clock –w //将日期写入cmos

时间按照上面的格式,操作完毕可以再用

date

查看服务器时间,如果和设置的一样,就表示成功了

以上所述是小编给大家介绍的centos7修改服务器系统时间的方法,希望对大家有所帮助

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网