4 ms·
Have you tried installing a cron daemon in WSL using your distro's package manager and starting it with, e.g., wsl -u root /usr/sbin/service <daemon-name> st
by jasomill 6y ago
Have you tried installing a cron daemon in WSL using your distro's package manager and starting it with, e.g.,
wsl -u root /usr/sbin/service <daemon-name> start
or, equivalently,
wsl -u root /etc/init.d/<daemon-name> start
Because I've been starting Debian sshd this way using a Windows Task Scheduler "At startup" task for years, in both WSL 1 and WSL 2, and it "just works".
Note that, for my case, WSL 2 requires an additional command to map a TCP port from external adapters to the VM's "host-only" interface, e.g.,
powershell.exe -NoProfile -NoLogo -Command
netsh interface portproxy add v4tov4
listenport=2022 listenaddress=0.0.0.0
connectport=2022 "connectaddress=$(
wsl -u root -e perl -e '
print qq{$1}
if qx{ip -br addr show eth0}
=~ m{ ([0-9.]+)/}')"
as a single line, replacing "2022" with the TCP port you want available externally.