-
Notifications
You must be signed in to change notification settings - Fork 817
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
WSL cannot be run by scheduled task #10732
Comments
@D3vil0p3r Please follow these steps to run a WSL 2 instance at system startup through the Task Scheduler service: You need to observe these restrictions to be able to do that:
|
/dupe 9231 |
@aki-k I'm not using a local admin account. I'm using a domain account that belongs to the group Administrators. Should I remove it from Administrators group to satisfy the 1. point? |
@D3vil0p3r If you mean the local group Administrators then probably yes. Edit: I created a separate local user account with no local Administrator group membership just for this "start WSL 2 at startup" task. |
Ok. So, there are some points I don't understand:
|
@D3vil0p3r That point 1. might be unnecessary after removing the local Administrator group membership. Point 2. was meant for the scenario when you want to create a Windows service to start up the WSL 2 instance at startup of the system. NSSM is a third party software to easily define Windows services. |
Ok. Once I set everything and I run the scheduled task, since you said I cannot login with the same username and running some wsl command, how can I know that WSL is actually running correctly on startup and it is up by my domain user account? |
@D3vil0p3r I use ssh or xpra to access it at localhost:22 (needs of course sshd or xpra installed in the WSL 2 instance to do it and enabling sshd password access (or sshd key setup) |
It is not working. On WSL Ubuntu I setup correctly the SSH service and I tested it runs correctly. About the scheduled task, what I did is on my Windows Server 2022:
Then, on the Windows Server I ensure that this domain user account is not logged in, and I use a different user account to run the created scheduled task and to run Putty to check if I can access to the SSH service inside WSL. When I manually trigger the scheduled task, SSH service is not running, so I guess WSL is not starting correctly on behalf of the previous cited domain user. Note that I'm not using systemd for running services. I'm using init.d for running sshd |
@D3vil0p3r Unfortunately I don't use a Windows domain or Windows Server os. |
@D3vil0p3r Did you notice that I couldn't make it work with Microsoft's systemd implementation? |
What do you mean |
@D3vil0p3r I wrote about it here |
/dupe #9231 |
Hi! We've identified this issue as a duplicate of another one that already exists in this repository. This specific instance is being closed in favor of tracking the concern over on the referenced thread. Thanks for your report! |
Windows Version
Microsoft Windows [Version 10.0.20348.2031]
WSL Version
WSL-Version: 1.2.5.0
Are you using WSL 1 or WSL 2?
Kernel Version
Linux version 5.15.90.1-microsoft-standard-WSL2 (oe-user@oe-host) (x86_64-msft-linux-gcc (GCC) 9.3.0, GNU ld (GNU Binutils) 2.34.0.20200220) # 1 SMP Fri Jan 27 02:56:13 UTC 2023
Distro Version
Ubuntu 22.04
Other Software
No response
Repro Steps
On Windows Server 2022 open the Task Scheduler and create a new task.
In the Properties of this task, under Triggers, set:
Actions tab, create an action like:
Tested with this configuration:
When launched, the task will exit with 0x1 status (see details below) and running:
we don't get Ubuntu WSL.
I am aware of #8835 where it is shown a workaround but it seems to not work in order to start WSL.
The user used for this task belongs to Administrators group that is tied with Log on as a batch job.
Expected Behavior
Scheduled task ended by 0x0 code status.
Actual Behavior
Scheduled task ended by 0x1 code status and it failed in "Action completed" task category with the following message:
Diagnostic Logs
No response
The text was updated successfully, but these errors were encountered: