- 论坛徽章:
- 0
|
回复 1# qj_zhai
如果您是在Linux下的话可以通过su进行用户调用进行启动,通常我们会编写启动脚本如下,并放到/etc/init.d目录下- #!/bin/bash
- #
- # chkconfig: 2345 85 15
- # description: Starts and stops the Postgres Plus Advanced Server 9.1 database server
- # Postgres Plus Advanced Server Service script for Linux
- start()
- {
- startserver=0
- if [ -e "/opt/PostgresPlus/9.1AS/data/postmaster.pid" ]
- then
- pidofpro=`head -n 1 /opt/PostgresPlus/9.1AS/data/postmaster.pid`
- alive=`ps -p $pidofpro | grep $pidofpro`
- if [ "x$alive" != "x" ]
- then
- exit
- else
- startserver=1
- fi
- else
- startserver=1
- fi
- if [ $startserver != 0 ]
- then
- echo $"Starting Postgres Plus Advanced Server 9.1: "
- su - enterprisedb -c "LD_LIBRARY_PATH=/opt/PostgresPlus/9.1AS/lib:$LD_LIBRARY_PATH /opt/PostgresPlus/9.1AS/bin/pg_ctl -w start -D \"/opt/PostgresPlus/9.1AS/data\" -l \"/opt/PostgresPlus/9.1AS/data/pg_log/startup.log\""
-
- if [ $? -eq 0 ];
- then
- echo "Postgres Plus Advanced Server 9.1 started successfully"
- exit 0
- else
- echo "Postgres Plus Advanced Server 9.1 did not start in a timely fashion, please see /opt/PostgresPlus/9.1AS/data/pg_log/startup.log for details"
- exit 1
- fi
- fi
- }
- stop()
- {
- if [ -e "/opt/PostgresPlus/9.1AS/data/postmaster.pid" ]
- then
- pidofproc=`head -n 1 /opt/PostgresPlus/9.1AS/data/postmaster.pid`
- pidalive=`ps -p $pidofproc | grep $pidofproc`
-
- if [ "x$pidalive" != "x" ]
- then
- echo $"Stopping Postgres Plus Advanced Server 9.1: "
- su - enterprisedb -c "LD_LIBRARY_PATH=/opt/PostgresPlus/9.1AS/lib:$LD_LIBRARY_PATH /opt/PostgresPlus/9.1AS/bin/pg_ctl stop -m fast -w -D \"/opt/PostgresPlus/9.1AS/data\""
- fi
- fi
- }
- reload()
- {
- echo $"Reloading Postgres Plus Advanced Server 9.1: "
- su - enterprisedb -c "LD_LIBRARY_PATH=/opt/PostgresPlus/9.1AS/lib:$LD_LIBRARY_PATH /opt/PostgresPlus/9.1AS/bin/pg_ctl reload -D \"/opt/PostgresPlus/9.1AS/data\""
- }
- # See how we were called.
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- reload)
- reload
- ;;
- condrestart|restart)
- stop
- sleep 3
- start
- ;;
- status)
- su - enterprisedb -s /bin/bash -m -c "LD_LIBRARY_PATH=/opt/PostgresPlus/9.1AS/lib:$LD_LIBRARY_PATH /opt/PostgresPlus/9.1AS/bin/pg_ctl status -D \"/opt/PostgresPlus/9.1AS/data\""
- ;;
- *)
- echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}"
- exit 1
- esac
复制代码 |
|