Redhat/CentOS 6.x/7.x修改系统时区

简介:

一,需求分析说明

    由于项目游戏发行海外版本,游戏里的活动需要按海外时间进行,而海外阿里云主机默认是以东8区北京时间计时,故需要更改时区和时间!

二,修改linux系统时区 

1,修改默认时区

#ln -sf /usr/share/zoneinfo/Europe/London /etc/timezone 

2,选择时区

#tzselect

运行命令会出现交互提示,以欧洲伦敦为例

[root@ALISG]# 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.
#? 8
Please select a country.
 1) land Islands      18) Greece            35) Norway
 2) Albania          19) Guernsey            36) Poland
 3) Andorra          20) Hungary            37) Portugal
 4) Austria          21) Ireland            38) Romania
 5) Belarus          22) Isle of Man        39) Russia
 6) Belgium          23) Italy            40) San Marino
 7) Bosnia & Herzegovina  24) Jersey            41) Serbia
 8) Britain (UK)      25) Latvia            42) Slovakia
 9) Bulgaria          26) Liechtenstein        43) Slovenia
10) Croatia          27) Lithuania            44) Spain
11) Czech Republic      28) Luxembourg        45) Sweden
12) Denmark          29) Macedonia            46) Switzerland
13) Estonia          30) Malta            47) Turkey
14) Finland          31) Moldova            48) Ukraine
15) France          32) Monaco            49) Vatican City
16) Germany          33) Montenegro
17) Gibraltar          34) Netherlands
#? 8

The following information has been given:
    Britain (UK)

Therefore TZ='Europe/London' will be used.
Local time is now:    Fri Jul 28 07:43:08 BST 2017.
Universal Time is now:    Fri Jul 28 06:43:08 UTC 2017.
Is the above information OK?
1) Yes
2) No
#? 1

You can make this change permanent for yourself by appending the line
    TZ='Europe/London'; 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:
Europe/London

选择时区然后 添加到配置文件最后:

#vim /etc/profile   
TZ='Europe/London';export TZ 
#cat /etc/sysconfig/clock 
ZONE="UTC" 
退出再登录查看时间 
#date 
2017年 07月 28日 星期四 08:07:30 BST 
3,写入硬件时钟 
#sudo hwclock -w 










本文转自 dyc2005 51CTO博客,原文链接:http://blog.51cto.com/dyc2005/1951722,如需转载请自行联系原作者
目录
相关文章
|
11天前
|
Linux 应用服务中间件 nginx
CentOS系统下的软件安装与卸载
CentOS系统中安装及卸载软件,常用yum命令安装及卸载软件包。yum是基于RPM的软件包管理器,可用于在CentOS中安装、更新、查询和移除软件包。yum命令可以从指定服务器下载rpm包并安装,能自动解决依赖问题。
120 78
|
2月前
|
运维 监控 安全
CentOS 7系统 OpenSSH和OpenSSL版本升级指南
本文详细介绍如何在CentOS 7系统上升级OpenSSH和OpenSSL至最新稳定版本(OpenSSH 9.6p1和OpenSSL 1.1.1w),解决多个已知安全漏洞(如CVE-2023-51767等)。涵盖环境说明、现存漏洞、升级准备、具体步骤及故障排查,确保服务器安全。建议先在测试环境验证,再应用于生产环境。
200 7
|
4月前
|
Web App开发 搜索推荐 Unix
Linux系统之MobaXterm远程连接centos的GNOME桌面环境
【10月更文挑战第21天】Linux系统之MobaXterm远程连接centos的GNOME桌面环境
863 4
Linux系统之MobaXterm远程连接centos的GNOME桌面环境
|
3月前
|
Linux 开发工具 Windows
CentOS8 64位系统 搭建内网穿透frp
【10月更文挑战第23天】本文介绍了如何在Linux系统上搭建frp内网穿透服务,并配置Windows客户端进行访问。首先,通过系统信息检查和软件下载,完成frp服务端的安装与配置。接着,在Windows客户端下载并配置frpc,实现通过域名访问内网地址。最后,通过创建systemd服务,实现frp服务的开机自动启动。
188 14
|
4月前
|
Linux 网络安全 数据安全/隐私保护
Linux系统之Centos7安装cockpit图形管理界面
【10月更文挑战第12天】Linux系统之Centos7安装cockpit图形管理界面
171 1
Linux系统之Centos7安装cockpit图形管理界面
|
3月前
|
存储 Linux Docker
centos系统清理docker日志文件
通过以上方法,可以有效清理和管理CentOS系统中的Docker日志文件,防止日志文件占用过多磁盘空间。选择合适的方法取决于具体的应用场景和需求,可以结合手动清理、logrotate和调整日志驱动等多种方式,确保系统的高效运行。
324 2
|
4月前
|
Linux 数据库 容器
Centos中将UTC的时区改为CTS时区
通过以上步骤,您就可以顺利地在CentOS系统中完成时区从UTC到中国标准时间(Asia/Shanghai)的更改了。
199 1
|
5月前
|
网络协议 Linux Shell
CentOS7系统命令学习笔记(一)
CentOS7系统命令学习笔记(一)
125 12
|
5月前
|
Linux
CentOS7系统命令学习笔记(二)
CentOS7系统命令学习笔记(二)
85 10
|
5月前
|
Linux Shell API
CentOS7系统命令学习笔记(三)
CentOS7系统命令学习笔记(三)
86 8