Powershell 远程作业在几个小时后被杀死

Powershell remote job getting killed after a few hours

我正在 运行 将远程作业作为部署的一部分,该作业应该 运行 永远(播种随机数据)但是仅几个小时后该过程就不断被杀死..我我在想一些缺少的远程服务标志或其他东西。

我正在 运行通过这个 powershell 命令执行远程作业

Invoke-Command -ComputerName DEPLY -Credential $cred -AsJob -ScriptBlock { 
    C:\Deply${bamboo.Configuration}\Seed\Seed.exe /y 
}

有什么办法可以防止这个进程被杀死吗?

所以在我看来,powershell 作业只有一个未记录的终止超时。我确认我的程序没有崩溃,远程服务只是在 3-4 小时后将其终止。或者可能是 OS 的事情——我不知道。

我切换到 psexec,这不会干扰进程 - 这是命令:

psexec \DEPLY -accepteula -d -u "corp\administrator" -p "xxx" C:\Deply${bamboo.Configuration}\Seed\Seed.exe /y

您也可以像这样通过 WMI 启动它:

$process = get-wmiobject -query "SELECT * FROM Meta_Class WHERE __Class = 'Win32_Process'" -namespace "root\cimv2" -computername DEPLY -credential $cred $results = $process.Create( "C:\Deply${bamboo.Configuration}\Seed\Seed.exe /y" )

但我无法确认以这种方式创建的远程进程是否会永远持续下去。每个测试需要 4 个小时,我已经搞定了。

相关:Launching background tasks in a remote session that don't get killed when the session is removed