修改时区比较简单,就是timedatectl set-timezone America/Los_Angeles加systemctl restart systemd-timesyncd,并且服务器重启后时区没有变回去还是修改后的
示例:
目前时区是UTC 0时区伦敦时间,想改成太平洋时区(Pacific Time,PT)的洛杉矶时间,PDT是指太平洋夏季时间(Pacific Daylight Time),PST是指太平洋标准时间(Pacific Standard Time)。太平洋夏季时间从每年3月的第二个星期日到11月的第一个星期日期间和北京时间差15小时,其余月份和北京时间差16小时。太平洋夏季时间时制结束后就是太平洋标准时间(Pacific Standard Time)。
root@LADB001:~# date Tue Nov 21 03:43:22 AM UTC 2023 root@LADB001:~# timedatectl Local time: Tue 2023-11-21 03:52:40 UTC Universal time: Tue 2023-11-21 03:52:40 UTC RTC time: Tue 2023-11-21 03:52:41 Time zone: Etc/UTC (UTC, +0000) System clock synchronized: no NTP service: active RTC in local TZ: no root@LADB001:~# cat /etc/timezone Etc/UTC root@LADB001:~# timedatectl list-timezones |grep Los America/Los_Angeles root@LADB001:~# timedatectl set-timezone America/Los_Angeles 备注:该操作等同于vim /etc/timezone替换文本中的内容为America/Los_Angeles root@LADB001:~# systemctl restart systemd-timesyncd root@LADB001:~# date Mon Nov 20 07:56:43 PM PST 2023 root@LADB001:~# timedatectl Local time: Mon 2023-11-20 20:04:34 PST Universal time: Tue 2023-11-21 04:04:34 UTC RTC time: Tue 2023-11-21 04:04:34 Time zone: America/Los_Angeles (PST, -0800) System clock synchronized: no NTP service: active RTC in local TZ: no root@LADB001:~# cat /etc/timezone America/Los_Angeles