ubuntu添加自启动

原创不易,转载请注明来源,谢谢

  1. 创建脚本 web

    #!/bin/bash
    # chkconfig: 2345 55 25
    # description: bt Cloud Service
    
    ### BEGIN INIT INFO
    # Provides:          web
    # Required-Start:    $all
    # Required-Stop:     $all
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: starts web
    # Description:       starts the web
    ### END INIT INFO
    sudo docker start mysql57
    sudo mount -t virtiofs ProjectWeb /www/wwwroot
    
  2. 添加到/etc/init.d下面

    ln -s xxx/web /etc/init.d/web
    
  3. 开启自启动

    systemctl enable web
    
  4. 如果不需要了 执行删除

    rm -rf /etc/init.d/web
    update-rc.d -f web remove
    
posted @ 2024-06-01 21:59  狂客  阅读(5)  评论(0编辑  收藏  举报