CentOS设置系统时间、硬件时间、以及定时校对时间

CentOS设置系统时间和时区
一、设置时区

方法一:使用setup工具
setup
选择Timezone configuration
选择Asia/Shanghai
空格键勾选上System clock uses UTC
就OK了。

方法二:使用tzselect工具
tzselect
选择亚洲Asia
5
选择国家China
9
选择地区central China
3
确认选择Yes
1
设置好tzselect后,一定要重写/etc/localtime
rm /etc/localtime
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

方法三:直接修改/etc/sysconfig/clock文件
vi /etc/sysconfig/clock
ZONE="Asia/Shanghai"
UTC=true
ARC=false
重写/etc/localtime
rm /etc/localtime
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

二、重启系统使时区生效
reboot

三、更新时间
更新系统时间
ntpdate cn.pool.ntp.org
更新硬件时间
hwclock --systohc

四、crontab定时较对时间
设置crontab定时较对时间
crontab -e
30 1 * * * ntpdate cn.pool.ntp.org ;hwclock --systohc

PS:
ntpdate命令安装
yum -y install ntp
setup工具安装
yum -y install setuptool
crontabs安装
yum -y install gcc gcc-c++ autoconf vixie-cron crontabs

  

posted @ 2017-10-31 15:36  繁华之路  阅读(546)  评论(0编辑  收藏  举报