首页 > 解决方案 > 从 windows 服务 c# 获取 Linux 服务器时间

问题描述

无论如何我可以从给定 linux 服务器 IP 的 windows 服务中获取 linux 服务器时间吗?我尝试使用 Cliwrap (https://github.com/Tyrrrz/CliWrap)并编写了以下函数,但它不能正常工作:

public string GetLinuxServerTime()
    {
        using (var cli = new Cli("bash.exe"))
        {
            // Execute
            var output = cli.Execute("ssh user@10.104.12.114 date");
            return "abc";
        }
    }

请建议一些其他方式。

标签: c#linuxwindows-services

解决方案


推荐阅读