麒麟系统安装后添加自启动
1. 在/etc/systemd/system/目录下新建文件rc-local.service
2.在文件中输入内容
# SPDX-License-Identifier: LGPL-2.1+
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as publishe
d by# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no
其中/etc/rc.local,为你需要自启动的内容文件
3. 在/etc目录下新建上述的rc.local,在文件中输入以下内容
#!/bin/bash
#
# 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.#your shell
#excample:/scu/autorun.shexit 0
其中/scu/autorun.sh是我设备需要运行的脚本,里面有驱动加载、应用程序等。
4. 在/scu/autorun.sh添加所需要运行的脚本或者程序。
5. 添加启动项
sudo chmod 775 /etc/rc.local
sudo systemctl enable rc-local
sudo systemctl start rc-local.service