[root@yjsyy-bcrdb-205 opt]# cat pg_restart.sh
#!/bin/bash
while true
do
ps aux|grep postgre|grep -v grep >/dev/null
if [ $? -ne 0 ];then
su - bcrdb -s /bin/sh -c '/opt/bcrdb/bin/pg_ctl start'
fi
done
添加开机自启
vim /etc/rc.d/rc.local
nohup sh /opt/pg_restart.sh &