Re:WSL Getting GUI Support
by Daneel_ on Saturday September 26, 2020 @09:46PM
(#24603549)
Bingo. The day I can put things in cron in WSL and have them run without needing a window open is the day I stop running a Linux VM.
[ Parent
| on HN ]
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.
Re:WSL Getting GUI Support
by nobody9999 on Saturday September 26, 2020 @11:05PM
(#24603898)
>he day I can put things in cron in WSL and have them run without needing a window open is the day I stop running a Linux VM.
You could have already been doing that for years[0].