activemq-start.sh
1.05 KB
#!/bin/bash
file_name="/var/log/activemq-run.log" # 日志文件
pid=0
proc_num() # 计算进程数
{
num=`ps -ef | grep "bin/linux-.*/wrapper.*ActiveMQ.pid" | grep -v grep | wc -l`
return $num
}
proc_id() # 进程号
{
pid=`ps -ef | grep "bin/linux-.*/wrapper.*ActiveMQ.pid" | grep -v grep | awk '{print $2}'`
}
proc_num
number=$?
echo $number >> $file_name
if [ $number -eq 0 ] # 判断进程是否存在
then
source /etc/profile && source /root/.bash_profile && source /root/.bashrc
/opt/ccc/activemq/bin/linux-x86-64/activemq start # 重启进程的命令,请相应修改
text=`date`
hn=`hostname`
#mail -s "$hn === $text, freeswitch restart" smithlp_2.0@163.com
proc_id # 获取新进程号
echo ${pid}, `date` >> $file_name # 将新进程号和重启时间记录
fi