日期:2014-05-16 浏览次数:20703 次
#!/bin/bash #配置文本目录 MQ_HOME="/usr/MQ" JDK_ROOT="/bin/jdk1.6.0_06" JDK_CMD="$JDK_ROOT/bin/java" echo "---------------------------------1" export_to_classpath_if_nonexistent() { if [ $# = 1 ]; then if ! echo $CLASSPATH | grep $1 > /dev/null; then export CLASSPATH=$CLASSPATH:$1 fi fi } #使JAVA环境变量生效 export JAVA_HOME=$JDK_ROOT export CLASSPATH=$JAVA_HOME/jre/lib:$JAVA_HOME/lib export PATH=$JAVA_HOME/bin:$PATH #导入程序所需要的jar 包 echo "---------------------------------2" export_to_classpath_if_nonexistent $MQ_HOME/bin export_to_classpath_if_nonexistent $MQ_HOME/lib/activemq-all-5.2.0.jar export_to_classpath_if_nonexistent $MQ_HOME/lib/MQ.jar export_to_classpath_if_nonexistent $MQ_HOME/lib/log4j-1.2.15.jar #这个是启动ActiveMQ Admin 服务程序,并将启动后的日志输出到日志文件中, 其中& 表示在后台运行,在用看门狗功能的时候,这几段需要注释掉 echo "---------------------------------3" /usr/apache-activemq-5.2.0/bin/activemq >> /usr/MQ/logs/activeMQServer.log & sleep 15 echo "Active MQ server started..." #进入MQForward 目录,运行接收转发消息程序 cd $MQ_HOME java com.mq.MQForward &
ps aux |grep java
ps -e | grep MQForward
ps aux|grep "activemq"|grep -v grep
#!/bin/bash # # # Source function library. . /etc/rc.d/init.d/functions MQFARWORD_PATH=/usr/MQ MQSERVER_PATH=/usr/apache-activemq-5.2.0 MQLOG_PATH=/usr/MQ/logs #控制改服务是否启动1 启动, 0 不启动 MQFarword=1 MQServer=1 start() { # Start daemons. date >> $MQLOG_PATH/MQ.log echo "Starting activeMQ......" >> $MQLOG_PATH/MQ.log while true; do #run activeMQ admin need to run,first run it! if !(ps aux|grep "activemq"|grep -v grep) >/dev/null ; then if [ -f $MQSERVER_PATH/bin/activemq ] && [ $MQServer = "1" ] ; then /usr/apache-activemq-5.2.0/bin/activemq >> $MQLOG_PATH/activeMQServer.log & echo "Starting activeMQ Server:" >> $MQLOG_PATH/MQ.log echo_success >> $MQLOG_PATH/MQ.log fi sleep 12 fi # run MQFarword if !(ps aux| grep "com.mq.MQForward" | grep -v grep) >/dev/null ; then if [ -f $MQFARWORD_PATH/activeMQ.sh ] && [ $MQFarword = "1" ] ; then /usr/MQ/activeMQ.sh >> $MQLOG_PATH/MQ.log echo "Starting MQForward:" >> $MQLOG_PATH/MQ.log echo_success >> $MQLOG_PATH/MQ.log fi fi sleep 30 done return 0 } # See how we were called. case "$1" in start) start ;; stop) stop ;; *) echo $"Usage: $0 {start|stop}" exit 1 esac exit $RETVAL