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 @ 2024-06-13 18:21  Leonardo-li  阅读(4)  评论(0编辑  收藏  举报