[关闭]
@lniwn 2017-09-21T14:48:39.000000Z 字数 627 阅读 810

Ubuntu16.10添加开机启动

Linux


1. 创建服务脚本

vim /etc/systemd/system/rc-local.service

  1. [Unit]
  2. Description=/etc/rc.local service
  3. After=network.target
  4. ConditionPathExists=/etc/rc.local
  5. [Service]
  6. Type=forking
  7. ExecStart=/etc/rc.local start
  8. TimeoutSec=0
  9. RemainAfterExit=yes
  10. [Install]
  11. WantedBy=multi-user.target

2. 编辑/etc/rc.local文件

  1. #!/bin/sh -e
  2. #
  3. # rc.local
  4. #
  5. # This script is executed at the end of each multiuser runlevel.
  6. # Make sure that the script will "exit 0" on success or any other
  7. # value on error.
  8. #
  9. # In order to enable or disable this script just change the execution
  10. # bits.
  11. #
  12. # By default this script does nothing.
  13. exit 0

3. 修改权限

  1. chown root:root /etc/rc.local
  2. chmod +x /etc/rc.local

4. 启动服务systemctl enable rc-local.service

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注