ElasticSearch - activemq - tomcat 开机自启动
[root@qwy ~]# cat /etc/init.d/elastisearch|grep -v '^#'
#!/bin/bash
# chkconfig: 2345 55 25
# description: SSH is a protocol for secure remote shell access.
export JAVA_HOME=/usr/local/java/jdk/
export JAVA_BIN=/usr/local/java/jdk/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH
case "$1" in
start)
su esuser<<!
cd /wxqyh/component/elasticsearch-6.2.2/
./bin/elasticsearch -d
!
echo "elasticsearch startup"
;;
stop)
es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'`
kill -9 $es_pid
echo "elasticsearch stopped"
;;
restart)
es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'`
kill -9 $es_pid
echo "elasticsearch stopped"
su esuser<<!
cd /wxqyh/component/elasticsearch-6.2.2/
./bin/elasticsearch -d
!
echo "elasticsearch startup"
;;
*)
echo "start|stop|restart"
;;
esac
exit $?
为启动脚本增加执行权限:chmod +x /etc/init.d/elasticsearch
配置开机启动es:chkconfig --add elasticsearch
[root@qwy ~]# cat /etc/init.d/activemq |grep -v '^#'
#!/bin/bash
# chkconfig: 2345 55 25
# description: SSH is a protocol for secure remote shell access.
export JAVA_HOME=/usr/local/java/jdk/
export JAVA_BIN=/usr/local/java/jdk/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH
export ACTIVEMQ_HOME=/wxqyh/component/apache-activemq-5.15.9/
case $1 in
start)
sh $ACTIVEMQ_HOME/bin/activemq start
;;
stop)
sh $ACTIVEMQ_HOME/bin/activemq stop
;;
status)
sh $ACTIVEMQ_HOME/bin/activemq status
;;
restart)
sh $ACTIVEMQ_HOME/bin/activemq stop
sleep 1
sh $ACTIVEMQ_HOME/bin/activemq start
;;
esac
exit 0
设置开机自动自动chkconfig activemq on 启动服务service activemq start https://blog.csdn.net/u012326462/article/details/84899788
[root@qwy ~]# cat /lib/systemd/system/tomcatportal.service [Unit] Description=tomcat After=network.target [Service] Environment="JAVA_HOME=/usr/local/java/jdk1.8.0_172" Type=oneshot ExecStart=/do1cloud/wxqyh/test/apache-tomcat-8.5.31_portal/bin/startup.sh ExecStop=/do1cloud/wxqyh/test/apache-tomcat-8.5.31_portal/bin/shutdown.sh ExecReload=/bin/kill -s HUP $MAINPID RemainAfterExit=yes [Install] WantedBy=multi-user.target (2).设置权限 chmod 754 tomcat.service (3).启动关闭服务,设置开机启动 #启动服务 systemctl start tomcat.service #关闭服务 systemctl stop tomcat.service #开机启动 systemctl enable tomcat.service https://www.cnblogs.com/taomylife/p/7992817.html
用一个例子来演示会更加清晰
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步