linux 修改时区并更新时间

edit system profile:

1
vi /etc/profile

add:

1
export TZ='Asia/Shanghai';

install ntpdate

1
2
apt-get install ntpdate
/usr/sbin/ntpdate asia.pool.ntp.org && /sbin/hwclock --systohc

add crontable

1
crontab -e

add:

1
/usr/sbin/ntpdate asia.pool.ntp.org && /sbin/hwclock --systohc

执行 “date”命令查看时间

分享到