更新时间:2021-02-22 18:17:28
rc.local脚本是一个Ubuntu开机后会自动执行的脚本,我们可以在该脚本内添加命令行指令。该脚本位于/etc/路径下,需要root权限才能修改。
该脚本具体格式如下。
注意: 命令需添加在 exit 0之前。
#!/bin/bash
#command content
exit 0
sudo chmod 755 new_service.sh
sudo mv new_service.sh /etc/init.d/
cd /etc/init.d/
sudo update-rc.d new_service.sh defaults 90
sudo update-rc.d -f new_service.sh remove