修改 linux 時區時間和 php 時區

2022-03-16 05:20:59 字數 1057 閱讀 6679

問題:客戶美國伺服器時間不對

第一步,先修改硬體時區。

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

yuminstall 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

ntpsystemctl enable ntpd

ntpdate -u cn.pool.ntp.org

systemctl start ntpd

#設定時區

timedatectl set-timezone asia/shanghai

Linux修改時區和時間

修改時區 1 找到相應的時區檔案 usr share zoneinfo asia shanghai 用這個檔案替換當前的 etc localtime檔案。或者找你認為是標準時間的伺服器,然後 scp root etc localtime etc localtime 2 修改 etc sysconfi...

檢視 修改Linux時區和時間

一 時區 1.檢視當前時區 date r 2.修改設定時區 方法 1 tzselect 方法 2 僅限於redhat linux 和 centos timeconfig 方法 3 適用於debian dpkg reconfigure tzdata 3.複製相應的時區檔案,替換系統時區檔案 或者建立鏈...

檢視 修改Linux時區和時間

檢視 修改linux時區和時間 一 時區 1.檢視當前時區 date r 2.修改設定時區 方法 1 tzselect 方法 2 僅限於redhat linux 和 centos timeconfig 方法 3 適用於debian dpkg reconfigure tzdata 3.複製相應的時區檔...