本文没有安装教程,安装教程请自行百度
1.redis
#在启动文件夹创建脚本文件
vim /etc/init.d/redis
文件内容
#!/bin/sh
# chkconfig: 345 86 14
# description: Redis is a persistent key-value database
PATH=/usr/local/redis/bin:/sbin:/usr/bin:/bin
REDISPORT=6379
EXEC=/usr/local/redis/bin/redis-server
REDIS_CLI=/usr/local/redis/bin/redis-cli
PIDFILE=/var/run/redis_6379.pid
CONF="/etc/redis.conf"
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF
fi
if [ "$?"="0" ]
then
echo "Redis is running..."
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$REDIS_CLI -p $REDISPORT SHUTDOWN
while [ -x ${PIDFILE} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
restart|force-reload)
${0} stop
${0} start
;;
*)
echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2
exit 1
esac
更改权限(可以省略)
chmod a+x /etc/init.d/tomcat
设置开机启动
chkconfig redis on
设置完成以后你可以使用下班,这个命令查看,下边有图
chkconfig --list
2.tomcat
创建脚本
vim /etc/init.d/tomcat
脚本内容
#!/bin/bash
#
# tomcat startup script for the Tomcat server
#
#
# chkconfig: 345 80 20
# description: start the tomcat deamon
#
# Source function library
. /etc/rc.d/init.d/functions
prog=tomcat
# 根据自己的路径改写JAVA_HOME
JAVA_HOME=/usr/lib/jvm/jdk1.8.0_161/
export JAVA_HOME
# 根据自己的路径改写CATALANA_HOME
CATALANA_HOME=/opt/apache-tomcat-8.0.50/
export CATALINA_HOME
case "$1" in
start)
echo "Starting Tomcat..."
$CATALANA_HOME/bin/startup.sh
;;
stop)
echo "Stopping Tomcat..."
$CATALANA_HOME/bin/shutdown.sh
;;
restart)
echo "Stopping Tomcat..."
$CATALANA_HOME/bin/shutdown.sh
sleep 2
echo
echo "Starting Tomcat..."
$CATALANA_HOME/bin/startup.sh
;;
*)
echo "Usage: $prog {start|stop|restart}"
;;
esac
exit 0
更改权限(可以省略)
chmod a+x /etc/init.d/tomcat
设置开机启动
chkconfig tomcat on
3.activemq
脚本文件
vim /etc/init.d/activemq
文件内容
#!/bin/sh
#
#/etc/init.d/activemq
# chkconfig: 345 63 37
# description: activemq servlet container.
# processname: activemq 5.15.2
# Source function library.
#. /etc/init.d/functions
# source networking configuration.
#. /etc/sysconfig/network
export ACTIVEMQ_HOME=/home/deployer/activemq/apache-activemq-5.15.8/bin/activemq
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
一样的 都可以使用 chkconfig --list 命令查看 是否成功设置