C# 从c杀死远程linux进程#

C# 从c杀死远程linux进程#,c#,.net,linux,kill-process,C#,.net,Linux,Kill Process,我想知道如何从c#按名称杀死远程linux进程 我试过使用pskill,但它不起作用……有人能帮我吗 string processName = "/bin/bash"; ProcessStartInfo pInfo = new ProcessStartInfo() { Arguments = $" -t {RemoteMachineName} -u {username

我想知道如何从c#按名称杀死远程linux进程 我试过使用pskill,但它不起作用……有人能帮我吗

string processName = "/bin/bash";
                    ProcessStartInfo pInfo = new ProcessStartInfo()
                    {
                        Arguments = $" -t  {RemoteMachineName} -u {username} -p {password} {processName}", // also kill all the child processes
                        CreateNoWindow = false,
                        RedirectStandardError = false,
                        RedirectStandardInput = false,
                        RedirectStandardOutput = false,
                        UseShellExecute = false,
                        FileName = ConfigurationManager.AppSettings["PsKillExecutablePath"]
                    };

                    var p = Process.Start(pInfo);
                    // wait for the process to exit 
                    p.WaitForExit(1000 * 60); // Wait for 60 seconds
                    if (p.ExitCode != 0)
                    {
                        logger.Error("Unable to kill the process on the remote machine ... ");
                    }
                    else
                    {
                        logger.Info("Sucessfully Killed remote process ... ");
                    }

也许只需使用
killall
命令?processName=
/usr/bin/killall
。你可以很容易地找到它的路径
,它杀死了所有的
@AdityaSingh,所以它是一个Windows工具。为什么你希望它对Linux机器做任何事情?我没有得到输出…它只是显示使用情况。。。pskill可以用于杀死远程linux上的进程吗machine@PanagiotisKanavos是的,我怀疑。。。那么如何从c#杀死linux远程进程。。。任何建议如果您想要跨平台工作,可以使用,前提是远程计算机上安装了Powershell Core。管理Linux的常用方法是通过SSH。但是.NET的SSH库很少。大多数人使用已经2年没有更新的