修改 linux 时区时间和 php 时区

问题:客户美国服务器时间不对

第一步,先修改硬件时区。

vim /etc/sysconfig/clock
将 ZONE="America/New_York" 注释,加多一行 ZONE="Asia/Shanghai"

第二步,修改系统时区

cp /etc/localtime /etc/localtime.bak
rm -rf /etc/localtime
ln -svf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
yum install ntpdate -y
ntpdate 0.centos.pool.ntp.org
date
clock -w         #将目前 Linux 的时间写到 BIOS 里面去!
clock -r         #检查 BIOS 里面的时间


第三步,修改 php.ini 的时区设置
date.timezone = PRC


第四步,写个 crontab 将时间同步(特殊情况下,加上这个)
#Ansible: Time synchronization
00 01 * * * /usr/sbin/ntpdate 0.centos.pool.ntp.org >/dev/null

怎样设置每次开机同步一次时间
vim /etc/rc.local
usr/sbin/ntpdate 0.centos.pool.ntp.org >/dev/null

 

--------------------------------------------------------------------------------------------------

上面是设置 centos6.5 的时区和时间的,下面说的是 centos7的

yum -y install ntp

systemctl enable ntpd

ntpdate -u cn.pool.ntp.org

systemctl start ntpd

#设置时区
timedatectl set-timezone Asia/Shanghai

 

转载于:https://www.cnblogs.com/chy1000/p/5864253.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值