博客园  :: 首页  :: 新随笔  :: 联系 :: 管理

Centos 7 添加开机启动

Posted on 2019-10-29 13:27  Mr.智  阅读(391)  评论(0编辑  收藏  举报

1、添加启动服务

添加docker开机启动服务

[root@localhost ~]# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

2、添加启动脚本

1、编写脚本

[root@localhost ~]# vi ping_route_donot_del.sh
ping 10.47.85.129 &
[root@localhost ~]# chomd +x ping_route_donot_del.sh

2、添加开机启动

[root@localhost ~]# vi /etc/rc.d/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.

touch /var/lock/subsys/local
/root/ping_route_donot_del.sh

3、赋予开机启动权限

[root@localhost ~]#chmod +x /etc/rc.d/rc.local