我想知道我可以通过哪种方式从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 ... ");
}