linux - 在 bash 中从外部服务器打印时间

标签 linux bash time synchronize ntp

我想知道是否可以简单地从外部服务器检索 Unix 时间戳(我想是使用 NTP)。我知道有 ntpd,它将当前系统时间更新为 NTP 服务器给出的时间,但我只想阅读 时间戳。是否可以在 Linux 中使用 Bash 命令?如果没有,我想我只需要编写一个 Python(或其他东西)应用程序来获取它并将其打印在 shell 上。

最佳答案

有些服务器提供daytime 守护进程,它可以以文本形式为您提供所需内容。

尝试:

telnet SERVER daytime

在您最喜欢的 SERVER 上。

示例成绩单:

pax$ telnet time.nist.gov daytime
Trying 192.43.244.18...
Connected to time.nist.gov.
Escape character is '^]'.

55860 11-10-26 06:33:38 12 0 0 438.2 UTC(NIST) *
Connection closed by foreign host.

关于linux - 在 bash 中从外部服务器打印时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7899326/

相关文章:

php - linux虚拟主机使用php连接到ms sql数据库-无法连接

linux - 以 root chown 文件并执行 bye group

bash - Bash 中的 boolean 运算符(&&、-a、||、-o)

java - 如何将 OffsetTime 转换为本地 OffsetTime?

linux - 检查我是否使用 sudo 或 su

arrays - 在 for 循环中设置命令

linux - 想要 grep 行中的特定单词并在文件中的该行下方添加一个新行

python - Bash 到 Python 的迁移

postgresql - 树莓派上的postgres docker容器时间总是错误的

python - Zabbix Server 的时间戳格式