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、加入的脚本必须是可以正确执行的

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