ln -fs /lib/systemd/system/rc-local.service /etc/systemd/system/rc-local.service
touch /etc/rc.local
chmod 755 /etc/rc.local
然后編輯rc.local 大概格式是這樣的:
!/bin/bash
service start ....
exit 0
然而蛋勺,WSL中并不支持通過rc.local 來實現(xiàn)開機啟動讥珍。在這有個偏方,可以通過windows 的啟動項來啟動 rc.local中的腳本策州。
win+r shell:startup <- 進入啟動目錄
創(chuàng)建一個VBScript腳本wls_rclocal.vbs
寫入內(nèi)容 , 通過bash命令參數(shù)去執(zhí)行rc.local
set ws=wscript.createobject("wscript.shell")
ws.run "C:\Windows\System32\bash.exe -c 'sudo /etc/rc.local'",0
原文地址:[https://blog.csdn.net/dz45693/article/details/89421129?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase](https://blog.csdn.net/dz45693/article/details/89421129?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase](https://blog.csdn.net/dz45693/article/details/89421129?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase](https://blog.csdn.net/dz45693/article/details/89421129?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase)