搜了这个网站和各种Q,很明显WSL是没有services和systemd的。每次启动电脑时,我都需要在 WSL 中运行一个程序,所以我阅读了有关如何使用 crontab 的页面:如何在 Windows 上运行 Ubuntu 服务(启动时)?| 超级用户,但我感到困惑,因为格式与 crontab 中的格式不符。但是,这是我的 cron:
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
PATH=cd /usr/local/src/:cd xmr-stak-cpu:cd bin/
@reboot . sudo ./xmr-stak-cpu
Run Code Online (Sandbox Code Playgroud)
我也这样做了:
启动时运行 bash/cron 循环
Create a file called linux.bat in shell:startup
Paste: C:\Windows\System32\bash.exe -c 'while [ true ]; do sudo /usr/sbin/cron -f; done'
Run Code Online (Sandbox Code Playgroud)
这是行不通的。
如何在 WSL 中运行服务?肯定有一种方法不需要我成为 Linux 博士吗?或者有没有办法使用Windows
因为在 Windows 中我尝试了以下操作:使用https://github.com/Microsoft/WSL/issues/612
Run: When the computer starts,
Action: Start a program,
Program: c:\Windows\system32\bash.exe,
Arguments: -c "sudo /xmr-stak-cpu/bin/xmr-stak-cpu -D"
Start in: /usr/local/src/
Run Code Online (Sandbox Code Playgroud)
正如您所猜测的,它仍然不起作用。坦率地说,我希望我能在 WSL 中做到这一点,因为这是我的首选方式,但我会采取任何方式。请帮助伙计们。