编辑文件:vi /etc/rc.local
vi /etc/rc.local
文件内容如下:
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
/usr/local/nginx/sbin/nginx
mosquitto -c /etc/mosquitto/mosquitto.conf -d
只要将要自动执行的命令加入到最后面就可以了
修改执行权限
chmod 755 rc.local
需要注意两点:
1、rc.local 必须摇有可执行权限
2、加入的脚本必须是可以正确执行的