云服务器 ECS Linux 服务器修改时区的两种方式

   2023-02-09 学习力0
核心提示: 在云服务器 ECS Linux 系统中,以 Centos6.5 为例,可以通过如下两种方式,修改系统时区:可以使用命令 tzselect,修改时区。操作示例:[root@localhost ~]# tzselectPlease identify a location so that time zone rules can be set correctly.Please sel

 

在云服务器 ECS Linux 系统中,以 Centos6.5 为例,可以通过如下两种方式,修改系统时区:

可以使用命令 tzselect,修改时区。操作示例:

[root@localhost ~]# tzselect
Please identify a location so that time zone rules can be set correctly.
Please select a continent or ocean.
 1) Africa
 2) Americas
 3) Antarctica
 4) Arctic Ocean
 5) Asia
 6) Atlantic Ocean
 7) Australia
 8) Europe
 9) Indian Ocean
10) Pacific Ocean
11) none - I want to specify the time zone using the Posix TZ format.
#? 5
Please select a country.
 1) Afghanistan           18) Israel                35) Palestine
 2) Armenia               19) Japan                 36) Philippines
 3) Azerbaijan            20) Jordan                37) Qatar
 4) Bahrain               21) Kazakhstan            38) Russia
 5) Bangladesh            22) Korea (North)         39) Saudi Arabia
 6) Bhutan                23) Korea (South)         40) Singapore
 7) Brunei                24) Kuwait                41) Sri Lanka
 8) Cambodia              25) Kyrgyzstan            42) Syria
 9) China                 26) Laos                  43) ***
10) Cyprus                27) Lebanon               44) Tajikistan
11) East Timor            28) Macau                 45) Thailand
12) Georgia               29) Malaysia              46) Turkmenistan
13) ***             30) ***              47) United Arab Emirates
14) India                 31) Myanmar (Burma)       48) Uzbekistan
15) Indonesia             32) Nepal                 49) Vietnam
16) Iran                  33) Oman                  50) Yemen
17) Iraq                  34) Pakistan
#? 9
Please select one of the following time zone regions.
1) east China - Beijing, Guangdong, Shanghai, etc.
2) Heilongjiang (except Mohe), Jilin
3) central China - Sichuan, Yunnan, Guangxi, Shaanxi, Guizhou, etc.
4) most of Tibet & ***
5) west Tibet & ***
#? 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:      Tue Jul 19 22:05:59 CST 2016.
Universal Time is now:  Tue Jul 19 14:05:59 UTC 2016.
Is the above information OK?
1) Yes
2) No
#? yes
Please enter 1 for Yes, or 2 for 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

 

通过修改配置文件修改时区

 


 

也可以直接通过修改配置文件来变更时区。

 

  1. vi /etc/sysconfig/clock
  2. ZONE=Asia/Shanghai(查/usr/share/zoneinfo下面的文件)
  3. rm /etc/localtime
  4. ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

 

[root@localhost zoneinfo]# ll /etc/localtime 
-rw-r--r--. 1 root root 2819 Jun 29 2015 /etc/localtime
[root@localhost zoneinfo]# cat /etc/sysconfig/clock
ZONE="America/Los_Angeles"
UTC=true
ARC=false
[root@localhost ~]# cd /usr/share/zoneinfo
[root@localhost zoneinfo]# ll
总用量 560
drwxr-xr-x.  2 root root  4096 Jun 29 2015 Africa
drwxr-xr-x.  6 root root  4096 Jun 29 2015 America
drwxr-xr-x.  2 root root  4096 Jun 29 2015 Antarctica
drwxr-xr-x.  2 root root  4096 Jun 29 2015 Arctic
drwxr-xr-x.  2 root root  4096 Jun 29 2015 Asia
drwxr-xr-x.  2 root root  4096 Jun 29 2015 Atlantic
drwxr-xr-x.  2 root root  4096 Jun 29 2015 Australia
drwxr-xr-x.  2 root root  4096 Jun 29 2015 Brazil
drwxr-xr-x.  2 root root  4096 Jun 29 2015 Canada
-rw-r--r--.  1 root root  2102 Oct 30 2008 CET
drwxr-xr-x.  2 root root  4096 Jun 29 2015 Chile
-rw-r--r--.  1 root root  2294 Oct 30 2008 CST6CDT
-rw-r--r--.  2 root root  2411 Oct 30 2008 Cuba
-rw-r--r--.  1 root root  1876 Oct 30 2008 EET
-rw-r--r--.  2 root root  9307 Oct 30 2008 Egypt
-rw-r--r--.  2 root root  3533 Oct 30 2008 Eire
-rw-r--r--.  1 root root   118 Oct 30 2008 EST
-rw-r--r--.  1 root root  2294 Oct 30 2008 EST5EDT
drwxr-xr-x.  2 root root  4096 Jun 29 2015 Etc
drwxr-xr-x.  2 root root  4096 Jun 29 2015 Europe
-rw-r--r--.  1 root root   255 Oct 30 2008 Factory
-rw-r--r--.  7 root root  3661 Oct 30 2008 GB
-rw-r--r--.  7 root root  3661 Oct 30 2008 GB-Eire
-rw-r--r--. 10 root root   118 Oct 30 2008 GMT
-rw-r--r--. 10 root root   118 Oct 30 2008 GMT0
-rw-r--r--. 10 root root   118 Oct 30 2008 GMT-0
-rw-r--r--. 10 root root   118 Oct 30 2008 GMT+0
-rw-r--r--. 10 root root   118 Oct 30 2008 Greenwich
-rw-r--r--.  2 root root  1135 Oct 30 2008 Hongkong
-rw-r--r--.  1 root root   119 Oct 30 2008 HST
-rw-r--r--.  2 root root  1141 Oct 30 2008 Iceland
drwxr-xr-x.  2 root root  4096 Jun 29 2015 Indian
-rw-r--r--.  2 root root  1622 Oct 30 2008 Iran
-rw-r--r--.  1 root root  4082 Oct 30 2008 iso3166.tab
-rw-r--r--.  3 root root  2197 Oct 30 2008 Israel
-rw-r--r--.  2 root root   481 Oct 30 2008 Jamaica
-rw-r--r--.  2 root root   331 Oct 30 2008 Japan
-rw-r--r--.  2 root root   211 Oct 30 2008 Kwajalein
-rw-r--r--.  2 root root   599 Oct 30 2008 Libya
-rw-r--r--.  1 root root  2102 Oct 30 2008 MET
drwxr-xr-x.  2 root root  4096 Jun 29 2015 Mexico
drwxr-xr-x.  2 root root  4096 Jun 29 2015 Mideast
-rw-r--r--.  1 root root   118 Oct 30 2008 MST
-rw-r--r--.  1 root root  2294 Oct 30 2008 MST7MDT
-rw-r--r--.  4 root root  2427 Oct 30 2008 Navajo
-rw-r--r--.  2 root root  2434 Oct 30 2008 NZ
-rw-r--r--.  2 root root  2018 Oct 30 2008 NZ-CHAT
drwxr-xr-x.  2 root root  4096 Jun 29 2015 Pacific
-rw-r--r--.  2 root root  2679 Oct 30 2008 Poland
-rw-r--r--.  2 root root  3439 Oct 30 2008 Portugal
drwxr-xr-x. 19 root root  4096 Jun 29 2015 posix
-rw-r--r--.  3 root root  3519 Oct 30 2008 posixrules
-rw-r--r--.  2 root root   405 Oct 30 2008 PRC
-rw-r--r--.  1 root root  2294 Oct 30 2008 PST8PDT
drwxr-xr-x. 19 root root  4096 Jun 29 2015 right
-rw-r--r--.  2 root root   724 Oct 30 2008 ROC
-rw-r--r--.  2 root root   380 Oct 30 2008 ROK
-rw-r--r--.  2 root root   402 Oct 30 2008 Singapore
-rw-r--r--.  3 root root  2721 Oct 30 2008 Turkey
-rw-r--r--.  2 root root   118 Oct 30 2008 UCT
-rw-r--r--.  6 root root   118 Oct 30 2008 Universal
drwxr-xr-x.  2 root root  4096 Jun 29 2015 US
-rw-r--r--.  6 root root   118 Oct 30 2008 UTC
-rw-r--r--.  1 root root  1873 Oct 30 2008 WET
-rw-r--r--.  2 root root  2194 Oct 30 2008 W-SU
-rw-r--r--.  1 root root 18724 Oct 30 2008 zone.tab
-rw-r--r--.  6 root root   118 Oct 30 2008 Zulu

 


备注:修改完时区需要重启生效,查看时区可以使用命令 date -R

 

 

 
反对 0举报 0 评论 0
 

免责声明:本文仅代表作者个人观点,与乐学笔记(本网)无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
    本网站有部分内容均转载自其它媒体,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责,若因作品内容、知识产权、版权和其他问题,请及时提供相关证明等材料并与我们留言联系,本网站将在规定时间内给予删除等相关处理.

  • 【强转】QEMU+GDB调试linux内核全过程
    【强转】QEMU+GDB调试linux内核全过程
    昨天更新了一篇名为《QEMU+GDB调试linux内核全过程》[link][https://blog.csdn.net/weixin_37867857/article/details/88138432]的博客,发现排版比较混乱,而且思维也比较混乱。咋一看下来简直是惨不忍睹,而且会给读者在安装过程中一种云里雾里的感觉,加上
    03-08
  • Linux下Bochs,NASM安装和使用 linux bom
    Linux下Bochs,NASM安装和使用 linux bom
    以Ubuntu为例,先更新一下:sudo apt-get updatesudo apt-get upgrade然后安装Bochs环境:sudo apt-get install build-essential xorg-dev libgtk2.0-dev安装NASMNASM官网下载,这以nasm-2.14.02.tar.gz为例:用tar zxvf nasm-2.14.02.tar.gz解压后编译安装cd
    03-08
  • 把玩Alpine linux(一):安装
    把玩Alpine linux(一):安装
    导读Alpine Linux是一个面向安全应用的轻量级Linux发行版。它采用了musl libc和busybox以减小系统的体积和运行时资源消耗,同时还提供了自己的包管理工具apk。Alpine 的内核都打了grsecurity/PaX补丁,并且所有的程序都编译为Position Independent Executabl
    03-08
  • 日志审计与分析实验三(rsyslog服务器端和客户端配置)(Linux日志收集)
    日志审计与分析实验三(rsyslog服务器端和客户
     Linux日志收集一、实验目的:1、掌握rsyslog配置方法2、配置rsyslog服务收集其他Linux服务器日志:C/S架构:客户端将其日志上传到服务器端,通过对服务器端日志的查询,来实现对其他客户端的日志进行集中管理;下面实现就是通过两套机器来实现,(server:19
    03-08
  • Linux学习系列--如何在Linux中进行文件的管理
    Linux学习系列--如何在Linux中进行文件的管理
    文件在常见的Linux的文件系统中,经常使用能了解到的文件管理系统是分为多个文件夹进行管理的。如何查看文件路径 pwd ,在文件目录中,会有一个点(.)代表的是当前目录,两个点(..)代表的是当前目录的上层目录在Linux下,所有以点开始的文件都是“隐藏文件
    03-08
  • [JetBrains] 我想在 Linux 上使用 macOS 键绑定!
    [JetBrains] 我想在 Linux 上使用 macOS 键绑定
    很高兴认识你,我的名字是kitakkun。我最近开始实习,是工程界的新手。顺便说一句,这是我的第一篇文章。你最喜欢的操作系统是什么?视窗?苹果系统?还是Linux?我将它们全部用于不同的目的,但感觉就像 macOS ≒ LinuxWindows。一两个月前,我最喜欢 Linux
    03-08
  • linux 配置Socks51
    linux 配置Socks51
    ***大家耳熟能详,但是socks用到的人比较少,那什么是socks呢?请看第二段或者百度百科,socks分别有4和5两个版本,现在5为主流。工作中经常用***访问国外,但是同时国内的速度又慢了,让人很纠结,实际上这个时候可以考虑使用socks。指定某一个程序使用国外s
    02-10
  • linux下如何单独编译设备树? linux设备树是什
    答: make vendor/device_name.dtb  如: make freescale/fsl-1043a-rdb.dtb
    02-10
  • linux下mysql开启远程访问权限及防火墙开放3306端口
    linux下mysql开启远程访问权限及防火墙开放3306
    开启mysql的远程访问权限默认mysql的用户是没有远程访问的权限的,因此当程序跟数据库不在同一台服务器上时,我们需要开启mysql的远程访问权限。主流的有两种方法,改表法和授权法。相对而言,改表法比较容易一点,个人也是比较倾向于使用这种方法,因此,这
    02-10
  • 移植linux3.7到nuc900系列开发板遇到的问题
    通过移植学习linux新版本内核,大概了解一下内核变化。记录一下移植过程中遇到的问题或值得注意的地方。1,添加一款arm9芯片的支持首先修改\arch\arm\tools\mach-types文件添加一行w90p950evbMACH_W90P950EVBW90P950EVB同目录下的脚本文件在编译内核时会根据
    02-10
点击排行