CentOS 添加开机启动脚本

生成脚本内容


# start nginx
# chkconfig 2345 10 90
/usr/local/nginx/sbin/nginx 
# start php
/usr/local/sbin/php-fpm
# start es
nohup /usr/local/elasticsearch-6.4.0/bin/elasticsearch & 
# start redis
nohup /usr/local/redis-4.0.10/src/redis-server ../redis.conf & 
# start mongodb
nohup /usr/local/mongodb/mongodb_3.6.5/bin/mongod --dbpath /usr/local/mongodb/mongodb_3.6.5/data --bind_ip 172.25.50.122 --port 27017 2>&1  &
# start mysql
nohup mysqld --defaults-file=/etc/my.cnf -u root 2>&1 &


添加脚本执行权限


chmod +x autostart.sh


配置启动项


chkconfig --add autostart.sh
chkconfig autostart.sh on
chkconfig --list

异常


service autostart.sh does not support chkconfig

在脚本的第二行添加 chkconfig 2345 10 90
#服务必须在运行级2,3,4,5下被启动或关闭,启动的优先级是90,关闭的优先级是10。

猜你喜欢

转载自blog.csdn.net/zhengjian0617/article/details/82585500