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

相关推荐
Molesidy7 小时前
【Linux】基于busybox的根文件系统的完善
linux·服务器·嵌入式linux
张龙6878 小时前
Docker 镜像瘦身实战:从 1.2GB 到 128MB,我踩过的 7 个坑和一套可复制的方法论
运维·后端·docker
zero_70328 小时前
HCIP 课程文字版思维导图笔记
服务器·网络·php
外滩运维专家9 小时前
Nginx 上的通配符证书 90 天到期,续签这事我是这么搞的
运维
科技新资讯10 小时前
国内AI影视制作服务商哪家口碑好
运维·人工智能·devops
jufeng130710 小时前
【系列:MiniKV 原理剖析 · 第 6 篇】
linux·软件工程·个人开发·makefile
IT摆渡者11 小时前
ubuntu系统网络问题
linux·运维·ubuntu
jufeng130711 小时前
【系列:MiniKV 原理剖析 · 第 5 篇】
linux·网络·c++·软件工程
kdxiaojie11 小时前
Linux 驱动研究 —— SDIO (1)
linux·运维·笔记·学习·sdio