Version
Version 10.0.22000.739
WSL Version
Kernel Version
5.10.102.1
Distro Version
Ubuntu-20.04
Other Software
WSL Version 60.0 and higher
Repro Steps
To start some services I created a script and added it to the event scheduler. It starts sshd and cron.
After the start of the system, if I am fast (2-3 minutes) I can observe that the script has been run.
After waiting a bit WSL has been shut down and is restarted when I open the terminal. Then the services do not run.
For simplicity follow these repro steps:
Create a task scheduler task:
<?xml version="1.0" encoding="UTF-16"?> <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"> <RegistrationInfo> <Date>2022-02-17T07:48:10.6191908</Date> <Author>username</Author> <URI>\test</URI> </RegistrationInfo> <Triggers /> <Principals> <Principal id="Author"> <UserId>S-1-5-21-2139355670-3375578443-2995265674-8217</UserId> <LogonType>InteractiveToken</LogonType> <RunLevel>HighestAvailable</RunLevel> </Principal> </Principals> <Settings> <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy> <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries> <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries> <AllowHardTerminate>true</AllowHardTerminate> <StartWhenAvailable>false</StartWhenAvailable> <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable> <IdleSettings> <StopOnIdleEnd>true</StopOnIdleEnd> <RestartOnIdle>false</RestartOnIdle> </IdleSettings> <AllowStartOnDemand>true</AllowStartOnDemand> <Enabled>true</Enabled> <Hidden>false</Hidden> <RunOnlyIfIdle>false</RunOnlyIfIdle> <WakeToRun>false</WakeToRun> <ExecutionTimeLimit>PT72H</ExecutionTimeLimit> <Priority>7</Priority> </Settings> <Actions Context="Author"> <Exec> <Command>C:\Windows\System32\wsl.exe</Command> <Arguments>--shutdown</Arguments> </Exec> <Exec> <Command>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe</Command> <Arguments>-windowstyle hidden -ExecutionPolicy Bypass C:\Users\username\test.ps1</Arguments> </Exec> </Actions> </Task>
Add into the Powershell script C:\Users\username\test.ps1:
bash.exe -c "sudo /opt/wsl-init.sh
Into /opt/wsl-init.sh add:
service cron start
Expected Behavior
Since the service is running all the time I expect the WSL session to stay active.
Actual Behavior
Since version 60 of WSL this does not work anymore. After a few minutes wsl --list --verbose shows that the WSL instance has been stopped.
Diagnostic Logs
#8611
WslLogs-2022-07-22_07-29-04.zip
Version
Version 10.0.22000.739
WSL Version
Kernel Version
5.10.102.1
Distro Version
Ubuntu-20.04
Other Software
WSL Version 60.0 and higher
Repro Steps
To start some services I created a script and added it to the event scheduler. It starts sshd and cron.
After the start of the system, if I am fast (2-3 minutes) I can observe that the script has been run.
After waiting a bit WSL has been shut down and is restarted when I open the terminal. Then the services do not run.
For simplicity follow these repro steps:
Create a task scheduler task:
<?xml version="1.0" encoding="UTF-16"?> <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task"> <RegistrationInfo> <Date>2022-02-17T07:48:10.6191908</Date> <Author>username</Author> <URI>\test</URI> </RegistrationInfo> <Triggers /> <Principals> <Principal id="Author"> <UserId>S-1-5-21-2139355670-3375578443-2995265674-8217</UserId> <LogonType>InteractiveToken</LogonType> <RunLevel>HighestAvailable</RunLevel> </Principal> </Principals> <Settings> <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy> <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries> <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries> <AllowHardTerminate>true</AllowHardTerminate> <StartWhenAvailable>false</StartWhenAvailable> <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable> <IdleSettings> <StopOnIdleEnd>true</StopOnIdleEnd> <RestartOnIdle>false</RestartOnIdle> </IdleSettings> <AllowStartOnDemand>true</AllowStartOnDemand> <Enabled>true</Enabled> <Hidden>false</Hidden> <RunOnlyIfIdle>false</RunOnlyIfIdle> <WakeToRun>false</WakeToRun> <ExecutionTimeLimit>PT72H</ExecutionTimeLimit> <Priority>7</Priority> </Settings> <Actions Context="Author"> <Exec> <Command>C:\Windows\System32\wsl.exe</Command> <Arguments>--shutdown</Arguments> </Exec> <Exec> <Command>C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe</Command> <Arguments>-windowstyle hidden -ExecutionPolicy Bypass C:\Users\username\test.ps1</Arguments> </Exec> </Actions> </Task>Add into the Powershell script C:\Users\username\test.ps1:
bash.exe -c "sudo /opt/wsl-init.shInto /opt/wsl-init.sh add:
service cron startExpected Behavior
Since the service is running all the time I expect the WSL session to stay active.
Actual Behavior
Since version 60 of WSL this does not work anymore. After a few minutes wsl --list --verbose shows that the WSL instance has been stopped.
Diagnostic Logs
#8611
WslLogs-2022-07-22_07-29-04.zip