系统之家 - 系统光盘下载网站!

当前位置:系统之家 > 系统教程 > CentOS6系统时区不对修改

CentOS6系统时区不对如何修改?

时间:2015-06-05 16:17:57 作者:qipeng 来源:系统之家 1. 扫描二维码随时看资讯 2. 请使用手机浏览器访问: https://m.xitongzhijia.net/xtjc/20150605/50193.html 手机查看 评论

  在CentOS6系统下,不知是什么原因导致时区日期不对,而有些程序的运行需要准确的时间,遇到问题应该对时区进行修复,那么要如何修复CentOS6系统时区呢?

CentOS6系统时区不对如何修改?

  通过tzselect设置过时区后,发现时间也不是北京时间,查看时区:

  liang@liang:~$ date +%z

  +0000

  很明显,时区不对,查看/etc/localtime,里面最后一个内容是UTC

  解决方法:

  liang@liang:~$ sudo cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

  liang@liang:~$ date +%z

  +0800

  liang@liang:~$ date

  2015年 05月 11日 星期五 18:56:39 CST

  实现Internet时间同步(这里可以忽略上面两步)

  方法1. 开机的时候自动网络校时:

  vi /etc/rc.d/rc.local

  /usr/sbin/ntpdate -u 192.168.0.2 192.168.0.3 192.168.0.4; /sbin/hwclock -w

  方法2. 设定计划任务

  crontab格式如下:

  # For details see man 4 crontabs

  # Example of job definition:

  # 。---------------- minute (0 - 59)

  # | 。------------- hour (0 - 23)

  # | | 。---------- day of month (1 - 31)

  # | | | 。------- month (1 - 12) OR jan,feb,mar,apr 。。。

  # | | | | 。---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat

  # | | | | |

  # * * * * * command to be executed

  设定crontab计划任务也有两种方式:

  1、写在/etc/crontab里

  代码:

  00 11 * * * root ntpdate 210.72.145.44

  每天11点与中国国家授时中心同步时间

  每天11点与中国国家授时中心同步时间

  当然前提是

  apt-get install ntpdate

  代码也可是

  00 11 * * * root ntpdate us.pool.ntp.org

  2、使用命令crontab -e

  crontab -e

  10 5 * * * root ntpdate us.pool.ntp.org;hwclock -w

  这样每天5:10自动进行网络校时,并同时更新BIOS的时间

  上面就是CentOS6时区不对修改的方法介绍了,当然如果不影响你系统的使用,也可不对时区进行调整。

发表评论

0

没有更多评论了

评论就这些咯,让大家也知道你的独特见解

立即评论

以上留言仅代表用户个人观点,不代表系统之家立场

其他版本软件

热门教程

人气教程排行

Linux系统推荐

扫码关注
扫码关注

扫码关注 官方交流群 软件收录