Linux应用开机启动的多种方式

方式一

1. vim /etc/rc.d/rc.local

2. 添加启动命令

3. chmod u+x /etc/rc.d/rc.local

方式二

1. cd /etc/rc.d/init.d/

2. touch xxx.sh && chmod u+x xxx.sh

3. vim xxx.sh

4. 添加如下内容

        #!/bin/bash
        # chkconfig: 2345 85 15
        # description: docker-compose
        具体的启动命令

方式三

1. cd /etc/systemd/system/

2. touch xxxx.service

3. vim xxxx.service

4. 添加如下内容

        [Unit]
        Description=docker compose service
        After=docker.service
 
        [Service]
        Type=simple
        User=root
        ExecStart=/usr/local/bin/docker-compose -f /usr/workspace/harbor/docker-compose.yml up -d 
        ExecStop=/usr/local/bin/docker-compose down 
        Restart=always
 
[Install]
WantedBy=multi-user.target

5. systemctl daemon-reload

6. systemctl enable xxxx.service

7. systemctl start xxxx.service

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值