Contents
wsl2下的问题
Windows10下linux子系统开机自启动cron等服务
https://xujinzh.github.io/2020/07/20/wsl-shell-startup/
https://newsn.net/say/wsl-auto.html
WSL 是 Windows10 Linux 子系统,它可以让Windows10用户无需安装虚拟机就可以使用Linux系统,非常的方便。但是,默认WSL不开启sshd服务,因此,会降低使用的便捷性,这里给出如何开启该服务,以及如何设置开机自启动其他服务,如 frp 等
- 在 Windows10 上,使用 windows + r 键,调出运行,输入 shell:startup 进入开机启动项文件夹
- 新建文件:wsl.vbs,名字自定义,但必须使用 vbs 作为扩展名
- 添加如下内容:(可以使用 notepad++ 打开)
Set ws = CreateObject("Wscript.Shell")
ws.run "wsl -d Ubuntu-18.04 -u root /etc/init.d/ssh start", vbhide
ws.run "wsl -d Ubuntu-18.04 -u root ~jinzhongxu/.frp.local/frpc -c ~jinzhongxu/.frp.local/frpc.ini", vbhide
ws.run "wsl -d Ubuntu-18.04 -u root /etc/init.d/zabbix-agent start", vbhide
ws.run "wsl -d Ubuntu-18.04 -u root cd ~jinzhongxu/.jan && ./jan", vbhide
其中的 “Ubuntu-18.04” 为默认的 WSL 名称,可以使用 cmd 命令:
wsl -l
// 结果如下:
适用于 Linux 的 Windows 子系统:
Ubuntu-18.04 (默认)
扩展内容:可以在cmd中直接输入 wsl 进入Linux子系统shell
linux子系统下,应用程序释放的内存,被用作cache,没有归还windows的问题
最终导致,Windows下大部分内存都被wsl吃掉了。
https://askubuntu.com/questions/155768/how-do-i-clean-or-disable-the-memory-cache
写个定时任务,定时drop掉cache
sudo crontab -e
*/15 * * * * root sync && echo 3 > /proc/sys/vm/drop_caches
System has not been booted with systemd as init system (PID 1). Can’t operate
暂未处理 (wsl2 ubuntu16.04)
发表回复