美文网首页
centos 时间同步API解决方法

centos 时间同步API解决方法

作者: 一回生 | 来源:发表于2020-08-25 17:44 被阅读0次

背景:

由于公司的环境比较特殊,服务器都需要使用代理才能上网,而代理只支持http、socks。 尝试使用redsocks、proxychains代理ntpdate无果的情况下,使用api获取当前时间,进行时间同步

实现方式

proxychains方式,报错如下,无法正常代理

[root@chain16 ~]# proxychains4 ntpdate -u ntp1.aliyun.com
[proxychains] config file found: /etc/proxychains.conf
[proxychains] preloading /usr/lib/libproxychains4.so
[proxychains] DLL init: proxychains-ng 4.1425 Aug 17:22:25
ntpdate[32353]: no server suitable for synchronization found                    

于是搜索了网上的做法,获取时间并进行设置

#方法一
date -s "$(curl -s http://quan.suning.com/getSysTime.do|jq '.sysTime2'|sed 's/\"//g')"
date -s $(curl -s http://worldtimeapi.org/api/timezone/Asia/Hong_Kong|jq '.datetime'|sed 's/\"//g')

以上方法以内jq json处理

需要安装

yum install epel-release
yum install jq

相关文章

  • centos 时间同步API解决方法

    背景: 由于公司的环境比较特殊,服务器都需要使用代理才能上网,而代理只支持http、socks。 尝试使用reds...

  • centos 时间同步

    0.asia.pool.ntp.org并不是固定的,大家可以选择任意一个,只要保证可用就OK。time.nist....

  • centos时间同步

    网络时间同步 查看硬件时间 系统时间写入硬件时间 硬件时间写入系统时间

  • centos时间同步

    参考:http://www.80vps.com/new6143.html[http://www.80vps.com...

  • Linux同步服务器时间

    Linux同步服务器时间 CentOS安装ntp时间同步服务[https://blog.csdn.net/yinj...

  • Windows同步服务器时间

    Windows同步服务器时间 CentOS安装ntp时间同步服务[https://blog.csdn.net/yi...

  • CentOS自动同步时间

    安装ntpdate 测试是否正常 设置定时任务 NTP服务器列表 参考: 全球可用的NTP服务器列表与解析服务 -...

  • Centos 时间ntp同步

    安装ntp服务器 yum install ntp 开始自启动 systemctl enable ntpd.serv...

  • centos 7 时间同步

    平时没注意虚拟机上centos的时间,今天date一下,发现时间不对 虽然是设置了CST的时间,时区也是重庆上海,...

  • Centos 同步系统时间

    安装ntpdate 同步

网友评论

      本文标题:centos 时间同步API解决方法

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