手机
当前位置:查字典教程网 >操作系统 >RedHat/Centos >CentOS系统中设置时间的基本方法总结
CentOS系统中设置时间的基本方法总结
摘要:1、安装ntp#yuminstallntp2、执行命令:#ntpdateus.pool.ntp.org。rhas5的时区是以文件形式存在的,...

1、安装ntp

#yum install ntp

2、执行命令:

#ntpdate us.pool.ntp.org 。

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

其他时区的文件存放在/usr/share/zoneinfo下

3、我们使用的是东八区(+0800),北京,上海的时间

所以将#cp -f /usr/share/zoneinfo/Asia/Shanghai拷贝到/etc/localtime

#cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime</p> <p>#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

二、时间

1、查看时间和日期

date

2、设置时间和日期

将CentOS系统日期设定成2011年11月30日的命令

date -s 11/30/11

将CentOS系统时间设定成下午09点13分0秒的命令

date -s 09:13:00

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

hwclock -w

三、定时同步时间

让系统时间与硬件时钟同步,用:

wclock –hctosys

#或

clock –hctosys

相反地,让硬件时钟与系统时间同步:

hwclock –systohc

#或

clock –systohc

让系统时间每隔十分钟去同步一下硬件时间。

[hqw@localhost root]$ vi /etc/crontab

SHELL=/bin/bash

PATH=/sbin:/bin:/usr/sbin:/usr/bin

MAILTO=root

HOME=/

# run-parts

01 * * * * root run-parts /etc/cron.hourly

02 4 * * * root run-parts /etc/cron.daily

22 4 * * 0 root run-parts /etc/cron.weekly

42 4 1 * * root run-parts /etc/cron.monthly

*/10 * * * * root hwclock --hctosys #加入此行,每隔10分钟执行一次hwclock --hctosys

【CentOS系统中设置时间的基本方法总结】相关文章:

在CentOS下安装和卸载图形化界面的方法

CentOS 6.6系统桌面字体怎么设置?

CentOS yum强行解除锁定的方法

在CentOS系统上安装Jetty服务器的教程

在CentOS 6.3中安装与配置Tomcat-7方法

在CentOS系统中使用yum安装指定版本软件的方法

在Linux系统中加密文件的方法

在CentOS系统中锁定软件版本阻止升级的方法

Linux系统下配置SSH方法

为CentOS系统设置网易下载源的方法

精品推荐
分类导航