編輯文件: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、加入的腳本必須是可以正確執行的