嵌入式爱好者

T507 ubuntu系统开机自启脚本

2022-4-24 15:31| 发布者: tanglu| 查看: 655| 评论: 0|原作者: tanglu

类目: 知识库  >  T507系列产品     文档编号: 632

T507 Ubuntu系统开机自启脚本是rc.local ,客户如果直接修改rc.local 文件,启机后存在修改的内容不生效的问题。具体原因和修改方法如下:

18.04及以上系统取消了rc.local自启动功能,因此不能像ubuntu16一样通过编辑rc.local来设置开机启动脚本。所以我们需要先打开rc.local自启动功能。

1、建立rc-local.service文件

sudo vim /etc/systemd/system/rc-local.service
输入如下内容
[Unit]
Description=/etc/rc.local Compatibility
ConditionPathExists=/etc/rc.local
 
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
 
[Install]
WantedBy=multi-user.target

2、创建rc.local
sudo vim /etc/rc.local

输入如下内容,注意加入sshd服务启动
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
echo "rc.local start" > /usr/local/test.log
/etc/init.d/ssh start
source ~/.bashrc
exit 0

3、rc.local加上权限
sudo chmod +x /etc/rc.local

4、启用服务
sudo systemctl enable rc-local

待您成功开启rc.local 自启功能之后,您再对rc.local开机自启脚本进行修改,保存后重启,测试修改是否生效。


已解决

未解决

只是看看

最新评论

QQ|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )

GMT+8, 2024-4-26 17:03

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

返回顶部