linux配置开机启动脚本

it2025-01-07  8

做个记录,在rhel7.6服务器中配置开机启动自定义程序

a:在文件/etc/rc.d/rc.local中新增需要启动得程序路径或者脚本路径

cat  /etc/rc.d/rc.local

/mapservice/mapservicestart.sh #nohup /mapservice/nginx-1.9.9/sbin/nginx #nohup /mapservice/redis-3.2.1/bin/redis-server /mapservice/redis-3.2.1/bin/redis.conf #nohup /mapservice/tomcat-7-QXGL-3737/bin/startup.sh     #nohup /mapservice/jdk1.8.0_271/bin/java -Dfile.encoding=utf-8 -jar /mapservice/FSearch/founder-FSearch.jar --spring.config.location=/mapservice/FSearch/application.properties #nohup /mapservice/jdk1.8.0_271/bin/java -Dfile.encoding=utf-8 -jar /mapservice/sdk_server/FSDKServer-0.0.1-SNAPSHOT.jar --spring.config.location=/mapservice/sdk_server/application.properties

b:设置rc.local文件权限

chmod +x /etc/rc.d/rc.local

c:将需要开机启动的程序加到下面脚本文件中,java程序需要按照下面格式来配置,否则会卡在第一个java程序上。

vi  /mapservice/mapservicestart.sh

#!/bin/bash nohup /mapservice/nginx-1.9.9/sbin/nginx nohup /mapservice/redis-3.2.1/bin/redis-server /mapservice/redis-3.2.1/bin/redis.conf nohup /mapservice/tomcat-7-QXGL-3737/bin/startup.sh     nohup /mapservice/jdk1.8.0_271/bin/java -Dfile.encoding=utf-8 -jar /mapservice/FSearch/founder-FSearch.jar --spring.config.location=/mapservice/FSearch/application.properties >>/mapservice/FSearch/FSearch.log 2>&1 & nohup /mapservice/jdk1.8.0_271/bin/java -Dfile.encoding=utf-8 -jar /mapservice/sdk_server/FSDKServer-0.0.1-SNAPSHOT.jar --spring.config.location=/mapservice/sdk_server/application.properties >>/mapservice/sdk_server/FSDKServer.log 2>&1 &

d:设置脚本文件执行权限

chmod +x /mapservice/mapservicestart.sh

 

最后将服务器重新启动查看效果。

 

最新回复(0)