Linux(CentOS)启动时自动执行脚本(rc.local)

下面说说通过rc.local文件进行开机启动

1、首先创建一个启动脚本,这里以启动docker为例

创建 docker-startup.sh 脚本

#! /bin/bash

/usr/bin/mk-docker-opts.sh -c
systemctl daemon-reload
systemctl restart docker

 

并给 docker-startup.sh 设置执行权限:

chmod +x docker-startup.sh

 

2、在 /etc/rc.local 末尾增加 docker-startup.sh 脚本

# vim /etc/rc.local
# 追加到末尾即可
# /root/shell/docker-startup.sh

 

并给 rc.local 设置执行权限

chmod +x /etc/rc.local

 

3、重新启动,验证结果。

posted on 2019-11-29 09:36  Ruthless  阅读(5669)  评论(0编辑  收藏  举报