ubuntu18.04以上版本使用systemd 开启自启动服务

进入/etc/systemd/system/目录,创建myscript.service,并赋予权限

sudo vim /etc/systemd/system/myscript.service

Unit

Description=My Script Service

After=network.target

Service

User=root

ExecStart=/home/start.sh

Restart=always

Install

【其中User是开发板的用户名,米尔为root,
否则查看运行状态显示 myscript.service: Failed to determine user credentials: No such process
ExecStart是执行脚本,使用绝对路径表示】

输入一下指令:

sudo systemctl daemon-reload

sudo systemctl start myscript.service

sudo systemctl enable myscript.service

重启开发板后查看服务开启状态

sudo systemctl status myscript.service

关闭自启动服务

sudo systemctl stop myscript.service

sudo systemctl disable myscript.service

相关推荐
取经蜗牛10 小时前
Ubuntu 国内镜像源配置指南(多版本常用镜像地址都有)
linux·运维·ubuntu
tedcloud12310 小时前
RTK部署教程:构建稳定的AI Workflow环境
服务器·javascript·人工智能·typescript·ocr
实心儿儿11 小时前
Linux —— 线程控制(1)
linux·运维·服务器
筠筠喵呜喵11 小时前
Linux软件开发性能优化
linux·c++·性能优化
Bruce_kaizy12 小时前
c++ linux环境编程——文件io介绍以及open 、write 、read 三剑客深度详解
linux·服务器·c++·ubuntu·操作系统·文件io
亦良Cool12 小时前
VMware虚拟机ubuntu瘦身,解决虚拟机越用越大
linux·运维·ubuntu
星辰&与海13 小时前
KVM + QEMU虚拟化方案
linux·运维
宋浮檀s14 小时前
应急响应——恶意流量&攻击行为识别
linux·运维·网络·网络安全·应急响应
REDcker14 小时前
Linux OverlayFS详解
java·linux·运维
Royzst14 小时前
xml知识点
java·服务器·前端