vmIdleTimeout has no effect #8659
-
VersionVersion 10.0.22000.739 WSL Version
Kernel Version5.10.102.1 Distro VersionUbuntu 20.04 Other SoftwareNo response Repro StepsInto %userprofile%/.wslconfig add: In Powershell run Start WSL by opening a Terminal. Check the current state of the machine by running in powershell: It should show STATE Running. Expected BehaviorCheck again, after for example 5 minutes. Actual BehaviorCheck again, after for example 5 minutes. Diagnostic Logs |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 9 replies
-
I was thinking the same thing for most of today, but believe it or not, it appears to be working as intended. The documentation wording on this feature is accurate, but confusing:
Technically, it should say "the VM", because there's only one WSL2 virtual machine running. The confusion is that this refers to the managed VM running WSL2 itself, not the WSL2 distribution/container/instance. There are two timers that are in play here:
So once you exit the last WSL2 distribution/instance, assuming no other processes are running in the background:
So setting Side note: You can also watch the VM shut down if you turn on |
Beta Was this translation helpful? Give feedback.
-
So, till now, if I want to keep wsl2 instance running always, (assume that I have lots of docker container running on that, no matter there is active user session or not), the only way is to keep a user session open somewhere and ensure there will be always at least one active session? |
Beta Was this translation helpful? Give feedback.
-
This discussion seems to have ended even though the problem remains. You can enable systemd in WSL 2 with https://github.com/DamionGans/ubuntu-wsl2-systemd-script ( for Ubuntu-22.04 you need to patch enter-systemd-namespace with this DamionGans/ubuntu-wsl2-systemd-script#36 (comment) ) After this, WSL 2 keeps on running even if you close all shells/terminals. Edit: by default that script enables systemd target basic.target but you can change that in both enter-systemd-namespace and start-systemd-namespace |
Beta Was this translation helpful? Give feedback.
-
I just made some tests, always using wsl.exe --shutdown, after every vmIdleTimeout modification I made. Whatever the vmIdleTimeout value, the Debian WSL2 instance was automatically stopped, 15 seconds after closing its terminal window. I watched its status, by running: wsl.exe -l -v in a command prompt. |
Beta Was this translation helpful? Give feedback.
-
I talked with the Bing AI, and here is the last part of the discussion. I installed the tmux package in Debian WSL2. When I ran it once, as a user (not root), and closed the terminal window, the Debian instance kept running indefinitely. This is the solution indeed. |
Beta Was this translation helpful? Give feedback.
I was thinking the same thing for most of today, but believe it or not, it appears to be working as intended. The documentation wording on this feature is accurate, but confusing:
Technically, it should say "the VM", because there's only one WSL2 virtual machine running.
The confusion is that this refers to the managed VM running WSL2 itself, not the WSL2 distribution/container/instance.
There are two timers that are in play here:
The first timer is how long a WSL instance is idle before it is terminated. Think of this as a
ws…