Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote shell terminates after 8hours #325

Open
BLZB0B opened this issue Jul 22, 2021 · 1 comment
Open

Remote shell terminates after 8hours #325

BLZB0B opened this issue Jul 22, 2021 · 1 comment

Comments

@BLZB0B
Copy link

BLZB0B commented Jul 22, 2021

Hi,

I have an issue where I open a shell:

shell_id = self.protocol.open_shell()

and run a batch file:

command_id = self.protocol.run_command(shell_id, command, args)

One particular batch file I run, regularly takes over 9 hours to complete. however, the shell appears to terminate at exactly 8 hours. (the batch carries on running and completes an hour later).

from 8 hours onwards, when getting the output:

self._raw_get_command_output(shell_id, command_id)

a 400 error is returned. I guessing because the shell has died.

looking at the pywinrm protocol code, work was started to implement the lifetime param:

# if lifetime:

is there a reason this was pulled ? can it be put back easily? would it work?

I could probably do a pull request for this if I could get some background on why it was commented out ?

Phil

@BLZB0B
Copy link
Author

BLZB0B commented Oct 29, 2021

after a lot more digging...

https://docs.microsoft.com/en-us/windows/win32/winrm/installation-and-configuration-for-windows-remote-management#maxshellruntime

MaxShellRunTime
Specifies the maximum time, in milliseconds, that the remote command or script is allowed to execute. The default is 28800000.

WinRM 2.0: The MaxShellRunTime setting is set to read-only. Changing the value for MaxShellRunTime will have no effect on the remote shells.

so - no amount of setting the maxshellruntime from the command line will work - it will always default to 8 hours

I suspect if you had an old (winrm 1) install and modified the value to > 8hours, upgrading to winRM 2 or 3 has not reset the stored value to 8hours so still works with >8hour jobs.

the unknown answer is to the question : would enabling the lifetime parameter override this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant