---
title: "修改Centos的系统时间为北京时间"
author: "daodan988"
date: "2012-09-24T23:44:32Z"
tags: []
categories: ["操作系统"]
slug: "centos"
draft: false
lastmod: "2012-09-24T23:44:32Z"
id: 1684677
url: "https://daodan988.iteye.com/blog/1684677"
---

修改Centos的系统时间为北京时间
 
今天添加自动任务的时候发现服务器的时候不是北京时间，现在我们将它改为北京时间。
 
1.删除本地时间并设置时区为上海
rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
 
2.用date看下时间是否正确，不正确的话继续下面的操作，使用ntp同步一下时间
ntpdate stdtime.sinica.edu.tw  www.2cto.com  
 
3.如果提示command not found，那说明ntp没有安装，使用如下命令进行安装
yum -y install ntpdate ntp
 
安装完成后重新执行第二步命令。
执行完成后用date命令看看吧，是不是已经为北京时间了。