设置时区
1. 使用 tzselect 选择时区。
tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
…
5) Asia
…
#? 5
Please select a country.
…
9) China 26) Laos 43) Taiwan
…
#? 9
Please select one of the following time zone regions.
…
- east China - Beijing, Guangdong, Shanghai, etc.
…
#? 1
The following information has been given:
China east China - Beijing, Guangdong, Shanghai, etc.
Therefore TZ=‘Asia/Shanghai’ will be used.
Local time is now: Wed Jun 5 15:17:02 CST 2019.
Universal Time is now: Wed Jun 5 07:17:02 UTC 2019.
Is the above information OK?
- Yes
- No
#? 1
You can make this change permanent for yourself by appending the line
TZ=‘Asia/Shanghai’; export TZ
to the file ‘.profile’ in your home directory; then log out and log in again.Here is that TZ value again, this time on standard output so that you
can use the /usr/bin/tzselect command in shell scripts:
Asia/Shanghai
2. 将时区写入到 rc.local
文件路径:
/etc/rc.d/rc.local
文件内容:
TZ='Asia/Shanghai'; export TZ