systemctl管理shell脚本开机自启动

1.使用场景说明

     如果想使用我们的systemctl管理shell脚本开机自启动,可以试试如下方法

2.systemctl管理配置中

#要使用systemctl开机启动的脚步路径
ls
/data/shell/SO/container_management.sh

 

复制代码
#配置systemctl管理文件
[root@localhost SO]# cat /etc/systemd/system/ctrstart.service
[Unit]
Description=My Script
After=network.target

[Service]
Type=simple
ExecStart=/data/shell/SO/container_management.sh
Restart=on-failure

[Install]
WantedBy=multi-user.target
复制代码

 

#设置下次开机自启动
systemctl enable ctrstart.service
systemctl list-unit-files --type=service

 

3.业务脚本

[root@localhost SO]# cat container_management.sh 
#!/bin/bash
暂不做展示

 

posted @   Leonardo-li  阅读(327)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· 写一个简单的SQL生成工具
· Manus的开源复刻OpenManus初探
点击右上角即可分享
微信分享提示