record-start.sh
1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
file_name="/var/log/recordserver-run.log" # 日志文件
pid=0
proc_num() # 计算进程数
{
num=`ps -ef | grep "RECORD_run" | grep -v grep | wc -l`
return $num
}
proc_id() # 进程号
{
pid=`ps -ef | grep "RECORD_run" | 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
export PATH=/usr/local/sbin:/usr/bin:/bin:/usr/local/bin:.:$PATH
export PGPASSWORD=ccc
result=`psql -h 172.29.1.11 -p 5432 -U ccc -d ipcc -c "select 1" | grep "\-\-\-\-"`
if [ ${#result} -gt 0 ]
then
/opt/ccc/record/bin/run.sh start # 重启进程的命令,请相应修改
else
echo "pgpool down but postgresql haven't start now" >> $file_name
fi
text=`date`
hn=`hostname`
#mail -s "$hn === $text, freeswitch restart" smithlp_2.0@163.com
proc_id # 获取新进程号
echo ${pid}, `date` >> $file_name # 将新进程号和重启时间记录
fi