admin管理员组文章数量:1642331
一、tzselect设置时区
date -R #查看当期时区
tzselect #设置时区
设置后会提示永久生效的提示,提示信息如下:
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
按提示执行命令:
TZ='Asia/Shanghai'; export TZ
#配置用户目录下文件,追加内容TZ='Asia/Shanghai'; export TZ
vim /root/.bash_profile >> TZ='Asia/Shanghai'; export TZ
另设置时区永久生效方式
ll /etc/ |grep localtime #查看当前localtime被软连接地址
ll /usr/share/zoneinfo #查看目录种的时区
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
二 、ntpdate同步时间
# 安装ntp服务器
yum -y install ntp ntpdate
# 开启服务
service ntpd start
# 同步时间
ntpdate 192.168.125.133(红色部分改为自己的IP地址)
2.1、定时同步时间
# 命令,进入一个VI的编辑界面,添加如下任务
crontab -e
# 一分钟同步一次
*/1 * * * * /usr/sbin/ntpdate time-a.nist.gov s2m.time.edu ntp.sjtu.edu > /dev/null 2 >&1
# 查看是否已经成功添加
Crontab –l
2.2、ntp常用服务器
国内
cn.pool.ntp 中国开源免费NTP服务器
ntp1.aliyun 阿里云NTP服务器
ntp2.aliyun 阿里云NTP服务器
time1.aliyun 阿里云NTP服务器
time2.aliyun 阿里云NTP服务器
国外
time1.apple 苹果NTP服务器
time2.apple 苹果NTP服务器
time3.apple 苹果NTP服务器
time4.apple 苹果NTP服务器
time5.apple 苹果NTP服务器
time1.google 谷歌NTP服务器
time2.google 谷歌NTP服务器
time3.google 谷歌NTP服务器
time4.google 谷歌NTP服务器
pool.ntp 开源免费NTP服务器
版权声明:本文标题:Linux设置系统时区以及同步系统时间 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dongtai/1729335569a1196935.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论