/etc/rc.d 中
文件会在 Linux 系统各项服务都启动完毕之后再被运行
#!/bin/sh #chkconfig: 2345 80 90 #description:auto_run echo "启动es" ES_PID=`ps -ef | grep elasticsearch | grep -v grep | awk '{print $2}'` if [ ! -z "$ES_PID" ] ; then echo "es is runing...pid:$ES_PID" else echo "start es" cd '/data/tools/elasticsearch-7.3.0/bin' ph=`pwd` echo "$ph" su - elasticsearch -c 'sh /data/tools/elasticsearch-7.3.0/bin/elasticsearch -d;exit' fi echo "启动nacos" NACOS_PID=`ps -ef | grep nacos | grep -v grep | awk '{print $2}'` if [ ! -z "$NACOS_PID" ] ; then echo "nacos is runing...pid:$NACOS_PID" else echo "start nacos" cd /data/nacos/bin nohup sh startup.sh -m standalone & fi echo "启动redis" REDIS_PID=`ps -ef | grep redis | grep -v grep | awk '{print $2}'` if [ ! -z "$REDIS_PID" ] ; then echo "redis is runing...pid:$REDIS_PID" else echo "start REDIS" cd /data/tools/redis-4.0.2/src redis-server ../redis.conf fi echo "启动nginx" NGINX_PID=`ps -ef | grep nginx | grep -v grep | awk '{print $2}'` if [ ! -z "$NGINX_PID" ] ; then echo "nginx is runing...pid:$NGINX_PID" else echo "NGINX REDIS" /usr/local/nginx/sbin/nginx fi echo "启动MySQL" MYSQL_IS_START=`netstat -lntup |grep 3306|wc -l` if [ $MYSQL_IS_START -eq 1 ] ; then echo "mysql is runing..." else echo "start mysql" service mysqld start fi