linux 中 /etc/rc.local 設置開機自動執行腳本 比如啓動 php-fpm nginx

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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章