English
Appearance
English
Appearance
Many users who are new to WSL2 run into a "puzzle": Linux is installed, so why does it "shut down by itself" shortly after you close the terminal? Why can't it keep running?
This article first describes this behavior, then explains why Microsoft designed WSL this way, and finally shows how to use WSL Dashboard to start a keep-alive Linux distribution.
Have you experienced the following scenario?
NOTE
WSL2's default "idle timeout" is about 60 seconds: when there are no running processes in the distribution (for example, when you have closed all terminals), the WSL virtual machine shuts down automatically to free up system resources such as memory.
This behavior is the default design of WSL2 — it is neither a malfunction nor an error.
WSL2 runs a complete Linux kernel through a lightweight Hyper-V virtual machine (utility VM). Every running distribution genuinely consumes memory resources. If all distributions stayed resident in the background, a machine running several distributions at once would waste hundreds of MB or even GB of memory, slowing down the overall performance of the machine.
Windows' design philosophy is "allocate resources on demand, release what is not in use":
Therefore, WSL adopts a "start on demand, stop when idle" strategy, automatically returning resources such as memory to the system when they are not needed.
WSL's "automatic shutdown when idle" is like turning off the light when you leave a room: it saves energy and is more efficient. But for people who "need the light to stay on all the time", it is troublesome — and that is exactly where the need for keep-alive comes from.
TIP
If you need Linux to run continuously (for example, deploying services, running scheduled tasks, setting up a development server, etc.), please read the next chapter and use WSL Dashboard to keep your distribution alive.
WSL Dashboard provides two simple ways to keep your Linux distribution running.
In the "Installed Linux Distributions" list of WSL Dashboard:
After clicking, the distribution is immediately woken up and keeps running; as long as you do not stop it manually, it will not be shut down automatically due to idle. This method suits temporary keep-alive scenarios where you need Linux to keep running now.
In the "Installed Linux Distributions" list of WSL Dashboard:
After checking, the distribution starts automatically every time Windows starts/logs in, without any manual operation, achieving "keep-alive on boot". This method suits scenarios where Linux needs to stay online for a long time (such as development servers and resident services).
TIP