centos 同步时间和更改时区

在我们使用CentOS系统的时候,也许时区经常会出现问题,有时候改完之后还是会出错,下面我们就来学习一种方法来改变这个状况。如果没有安装,而你使用的是 CentOS系统 那使用命令 yum install ntp

然后:ntpdate us.pool.ntp.org 。

因为CentOS系统是用rhas的源码再编译的,很多地方是完全一样的。

rhas5的时区是以文件形式存在的,当前的时区文件是在/etc/localtime

那么其他时区的文件存放在哪里呢?

在/usr/share/zoneinfo下

我们用东八区,北京,上海的时间

#cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
#reboot

重启之后,date查看时间、查看当前时区 date -R、查看/修改Linux时区和时间

一、时区

1. 查看当前时区
date -R

2. 修改设置时区
方法(1)
tzselect
方法(2) 仅限于RedHat Linux 和 CentOS系统
timeconfig
方法(3) 适用于Debian
dpkg-reconfigure tzdata

3. 复制相应的时区文件,替换CentOS系统时区文件;或者创建链接文件
cp /usr/share/zoneinfo/$主时区/$次时区 /etc/localtime
在中国可以使用:
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

二、时间

时间: 2024-08-05 05:22:51

centos 同步时间和更改时区的相关文章

centos 同步时间

centos系统时间同步和网络同步 一般新装的centos系统服务器有的时间可能不对或者设置了错误的时区,可以使用NTP从时间服务器同步. 1.把当前时区调整为上海+8区,想改其他时区也可以.在/usr/share/zoneinfo目录 cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 2.安装ntpdate yum install -y ntpdate 3.使用ntpdate同步标准时间(或者同步其他的时间服务器) ntpdate us.p

Linux系统(centos)同步时间方式

.删除本地时间并设置时区为上海 rm -rf /etc/localtime ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 1 yum install ntp ntpdate 2 ntpdate -u ntp.sjtu.edu.cn 202.120.2.101 3 date(同步成功后 查看日期时间  有时候同步不上 需要多同步几次) 4 写入硬件 hwclock -w 以下是国内常见的NTP服务器 ntp.sjtu.edu.cn 2

centos同步时间

ntpdate time.windows.com && hwclock -w

ubuntu/centos更改时区并同步系统时间

分享点小经验.之所以写这个文档是因为在做jenkins自动化发布代码的时候.svn不能获取到最新的源码.原因在于svn获取源码有两种方式:1.通过系统时间生成版本号:2.通过HEAD 默认就是时间.所以需要同步jenkins和svn的系统时间.又因为我用的svn是在ubuntu的系统上.ubuntu默认应该是南非的时区.所以同步的时间肯定和centOS的不一样.又牵扯到了修改系统的时区 此操作适用Ubuntu CentOS 1.查看时区: [[email protected] ~]# date

centos修改时区同步时间

查看服务器时间及所在时区 [[email protected] ~]# date -R Fri, 07 Dec 2018 04:38:28 -0500 修改时区 先使用 tzselect 根据提示选择所在地区,最终生成时区 You can make this change permanent for yourself by appending the line TZ='Asia/Shanghai'; export TZ to the file '.profile' in your home di

centos NTP同步时间

centos系统时间同步和网络同步 一般新装的centos系统服务器有的时间可能不对或者设置了错误的时区,可以使用NTP从时间服务器同步. 1.把当前时区调整为上海+8区,想改其他时区也可以.在/usr/share/zoneinfo目录 cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 2.安装ntpdate yum install -y ntpdate 3.使用ntpdate同步标准时间(或者同步其他的时间服务器) ntpdate us.p

Ubuntu 更改时区,时间

更改时区,时间 执行tzselect按照提示进行选择时区sudo cp /usr/share/zoneinfo/Asia/ShangHai /etc/localtime执行sudo ntpdate cn.pool.ntp.orgcn.pool.ntp.org是位于中国的公共NTP服务器,用来同步你的时间

Ubuntu 16.04 LTS 设定时区,同步时间

设定时区:dpkg-reconfigure tzdata 选择Asia -> 再选择Shanghai -> OK 同步时间命令: 1.sudo apt-get install ntpdate // 安装时间同步工具 2.sudo ntpdate cn.pool.ntp.org // 与网络服务器同步时间 3.date // 查看时间是否已同步

怎么让CentOS集群自动同步时间

怎么让CentOS集群自动同步时间?首先机器要连外网,这样才能从互联网上同步时间,这是首先要了解的.好了,主要的方法如下: 在除了运行ntpd之外的机器上,执行: [html] # chkconfig --list | grep ntpd 看看ntpd有没有开机自启动(如果显示的全为off则表明不是开机自启动),如果是开机自启动的,需要执行: [html] # chkconfig ntpd off 关闭ntpd,如果ntpd开着,ntpdate没办法从其他服务器同步时间的. 然后在/etc/rc