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

相关推荐
Elastic 中国社区官方博客21 分钟前
使用 Elastic 中的 OpenTelemetry 为 Nginx 实现端到端分布式追踪的实用指南
大数据·运维·分布式·elasticsearch·搜索引擎·信息可视化·全文检索
独自破碎E35 分钟前
配置ssh解决https不稳定的问题
运维·ssh
heartbeat..1 小时前
零基础学 SQL:DQL/DML/DDL/DCL 核心知识点汇总(附带连接云服务器数据库教程)
java·服务器·数据库·sql
那些年的笔记1 小时前
Linux屏幕旋转方法
linux·运维·服务器
XiaoHu02071 小时前
Linux网络编程套接字
linux·服务器·网络·git
竹之却2 小时前
CentOS 系列,防火墙相关指令
linux·运维·centos
gaize12132 小时前
科普篇“机架、塔式、刀片”三类服务器对比
运维·服务器
以太浮标2 小时前
华为eNSP模拟器综合实验之- VLAN聚合(VLAN Aggregation或Super VLAN)解析
运维·网络·华为·信息与通信
咕噜企业分发小米2 小时前
如何利用云服务器搭建游戏服务器并实现跨平台游戏?
运维·服务器·游戏
一颗青果2 小时前
进程组 | 会话 |终端 | 前台后台 | 守护进程
linux·运维·jvm