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

相关推荐
SelectDB13 小时前
Litefuse 开源并推出单进程轻量模式,25 秒就能跑起来的 Agent 可观测与评估平台
运维·后端·自动化运维
AlfredZhao13 小时前
Docker 容器时区不对,`timedatectl` 不存在怎么办?
linux·timezone
zzzzzz3102 天前
9K Star 炸裂开源!这个 C 语言写的代码知识图谱,把 Linux 内核索引压缩到了 3 分钟
linux·服务器·sql
XIAOHEZIcode2 天前
Linux系统鼠标偏移常见原因以及修复方案
linux·运维·游戏
用户0328472220703 天前
如何搭建本地yum源(上)
运维
A小辣椒4 天前
TShark:Wireshark CLI 功能
linux
A小辣椒4 天前
TShark:基础知识
linux
AlfredZhao4 天前
OCI 明明分配了 200G 系统盘,为什么 df 只看到 30G?
linux·oci
AlfredZhao5 天前
vi 删除指定范围的行,不用再反复按 dd
linux·vi
用户9718356334665 天前
银河麒麟 KY10 申威(SW64) 安装 nginx-1.16.1-2.p01.ky10.sw_64.rpm 详细步骤
linux