设置服务器开机服务自启,包括.sh脚本,docker,nginx等
编写/etc/rc/local文件
1、.sh 脚本文件
[root@localhost /]# cat /etc/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
/home/start_ms.sh
其中 start_ms.sh 文件即为所需开机启动的脚本,需要添加可执行权限 chmod +x
同时需要chmod +x /etc/rc.d/rc.local
,才能保证开机启动
2、docker、nginx
将docker、nginx服务设置开机启动即可
systemctl enable nginx.service
可以通过systemctl list-unit-files|grep enabled
查看已开启的服务