zoukankan      html  css  js  c++  java
  • rc.local(ubuntu18.04)

    系统自带服务/lib/systemd/system/rc-local.service

    软连接为 /lib/systemd/system/rc.local.service -> rc-local.service

    #  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 published 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

    可以看到此文件缺少[install]部分,为他加上。

    [Install]
    WantedBy=multi-user.target

    输入systemctl enable rc-local.service

    系统启动时将执行/etc/rc.local文件里的内容

    16.10开始不再有/etc/rc.local文件

    创建

    printf '%s
    ' '#!/bin/bash' 'exit 0' | sudo tee -a /etc/rc.local
    vim /etc/rc.local

    添加以下内容用于测试

    #!/bin/bash 
     
    touch /var/lock/subsys/local
    
    source /etc/profile
     
    echo `date`,"ok" >>/tmp/test-rc-local.log
    sudo chmod +x /etc/rc.local

    重启后看效果

  • 相关阅读:
    洛谷P5245 【模板】多项式快速幂
    洛谷P5205 【模板】多项式开根(FFT)
    laravel 数据库连接Mysql
    laravel V层引入css 和js方法
    laravel V层
    小程序地区时间自定义选择器 picker
    点击a标签 跳到当前页面指定div
    图片上下居中
    小程序消除图片下边距的三个方法
    百度地图定位
  • 原文地址:https://www.cnblogs.com/wintersoft/p/9942672.html
Copyright © 2011-2022 走看看