0

I am running a remote job as part of a deployment which is supposed to run forever (seeding random data) however the process keeps getting killed after only a few hours.. I am figuring some missing remote service flag or something.

I am running the remote job via this powershell command

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

Is there someway to prevent this process from being killed?

Charles
  • 3,734
  • 3
  • 31
  • 49
  • AFAIK jobs run indefinitely, this is also stated in the `Wait-Job` parameter `-Timeout`. This parameter has by default the value `-1`, so it should keep on waiting. Are you sure your `Seed.exe` isn't the one who stops working after a while? – DarkLite1 Nov 04 '15 at 10:16
  • Yeah - there is literally a white(true) in there.. lol. I write the log files to disk too, no exceptions or odd behavior.. it just silently closes. – Charles Nov 04 '15 at 17:22
  • 1
    If you want to be sure if it is `Seed.exe` or not who stops the job, you can put some code after it, within the job. And check with `Get-Job | Receive-Job` in the end of your script, to see if you see that last piece of code in the output. If not... then you know it's the `Seed.exe` that's crashing. A `Try/Catch` might be an option to. – DarkLite1 Nov 05 '15 at 08:07

1 Answers1

0

So it seems to me there is just an undocumented kill timeout for powershell jobs. I confirmed that my program is not crashing and the remoting service is just killing it after 3-4 hours. Or maybe its an OS thing - I don't know.

I switched to psexec which doesn't mess with the process - here is the command:

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

You can also launch it via WMI like so:

$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" )

But I can't confirm if a remote process created this way lasts forever. Each test takes 4 hours and Im done messing with this.

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

Community
  • 1
  • 1
Charles
  • 3,734
  • 3
  • 31
  • 49