美文网首页Linux
linux同步系统时间

linux同步系统时间

作者: dark68 | 来源:发表于2021-06-11 09:11 被阅读0次
1. 安装ntp ntpdate包,同步系统时间

yum install -y ntp ntpdate
ntpdate 0.asia.pool.ntp.org

然后使用date命令,查看系统时间是否同步


2. 同步系统时间到docker容器

这里示例同步php和nginx两个容器

docker cp /usr/share/zoneinfo/Asia/Shanghai php:/etc/localtime
docker cp /usr/share/zoneinfo/Asia/Shanghai nginx:/etc/localtime

先重启容器,然后进入容器使用date命令,查看时间是否同步

docker restart php
docker restart nginx
docker exec -it php bash

相关文章

网友评论

    本文标题:linux同步系统时间

    本文链接:https://www.haomeiwen.com/subject/foymeltx.html