记一次开启自启-sh脚本

继续潜水 / 2024-10-08 / 原文

 

vi /etc/systemd/system/mystartup.service

编辑文件

[Unit]
Description=Device Room Server Startup

[Service]
User=easwift
Group=easwift
Type=simple
ExecStart=/bin/bash /home/startup.sh
Restart=on-failure

[Install]
#WantedBy=multi-user.target

vi /home/startup.sh

#!/bin/bash

# 执行第一个脚本
sh /home/easwift/device_room/device_room_server/shellTool.sh restart
sleep 60
# 执行第二个脚本
#/path/to/your/script2.sh

# 可以继续添加其他脚本


chmod +x /home/startup.sh

开机自启:sudo systemctl enable mystartup