ubuntu开机自启动脚本

20.04及以上开机启动

开机启动服务脚本 autostart.service

[Unit]
Description=hdcollectapp auto start
After=network-online.target
 
[Service]
ExecStart=/xxx/xxx.sh
 
[Install]
WantedBy=multi-user.target

服务部署

#!/bin/bash

function service_install(){
   
    #参数从1开始  $1 ${10}
    #参数个数     $#
    #参数字符串   $*
    SVR=$1
    SRV_PATH="./${SVR}"
	echo ${SVR}
	sudo chmod 777 ${SRV_PATH}
	sudo cp -f ${SRV_PATH} /etc/systemd/system
	sudo systemctl daemon-reload
	sudo systemctl enable ${SVR}
	sudo systemctl start ${SVR}
}
SERVICE_LIST=("xxx1.service" "xxx2.service")
for SVR in ${SERVICE_LIST[@]}; 
do
	service_install SVR
done
 
停止开机启动
sudo systemctl disable ${SVR}

相关推荐

  1. ubuntu开机启动脚本

    2024-01-05 20:04:01       53 阅读
  2. Ubuntu 20.04中设置开机启动脚本

    2024-01-05 20:04:01       43 阅读
  3. Ubuntu22.04配置脚本开机启动

    2024-01-05 20:04:01       26 阅读
  4. Ubuntu 设置开机启动脚本

    2024-01-05 20:04:01       22 阅读
  5. 开机启动脚本配置

    2024-01-05 20:04:01       31 阅读
  6. Linux设置开机启动脚本

    2024-01-05 20:04:01       34 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-05 20:04:01       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-05 20:04:01       100 阅读
  3. 在Django里面运行非项目文件

    2024-01-05 20:04:01       82 阅读
  4. Python语言-面向对象

    2024-01-05 20:04:01       91 阅读

热门阅读

  1. 3D立体盒子练习

    2024-01-05 20:04:01       53 阅读
  2. MacBook安装telnet工具和使用

    2024-01-05 20:04:01       70 阅读
  3. @Service Spring required a bean could not be found.

    2024-01-05 20:04:01       60 阅读
  4. 1.3数组

    1.3数组

    2024-01-05 20:04:01      58 阅读