How to run Postgresql as a service
#vim /etc/init.d/postgresql
Copy the below Script to /etc/init.d/postgresql
#!/bin/sh -e
# description: Postgresql SQL Server
# chkconfig: 2345 99 00
PGVER='9.2'
BINPATH="/opt/PostgreSQL/9.0/postgres/bin/"
PGUSER='postgres'
PGLOG='/opt/PostgreSQL/9.0/postgres/data/logfile'
PGDIR='/opt/PostgreSQL/9.0/postgres/data'
start()
{
cd $BINPATH
su - $PGUSER -c "$BINPATH/pg_ctl -D $PGDIR -l $PGLOG start"
}
stop()
{
cd $BINPATH
su - $PGUSER -c "$BINPATH/pg_ctl -D $PGDIR -l $PGLOG stop"
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0
and save it by :wq
#chkconfig postgresql on /*start the postgresql while boot*/
#service postgresql start
Copy the below Script to /etc/init.d/postgresql
#!/bin/sh -e
# description: Postgresql SQL Server
# chkconfig: 2345 99 00
PGVER='9.2'
BINPATH="/opt/PostgreSQL/9.0/postgres/bin/"
PGUSER='postgres'
PGLOG='/opt/PostgreSQL/9.0/postgres/data/logfile'
PGDIR='/opt/PostgreSQL/9.0/postgres/data'
start()
{
cd $BINPATH
su - $PGUSER -c "$BINPATH/pg_ctl -D $PGDIR -l $PGLOG start"
}
stop()
{
cd $BINPATH
su - $PGUSER -c "$BINPATH/pg_ctl -D $PGDIR -l $PGLOG stop"
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0
and save it by :wq
#chkconfig postgresql on /*start the postgresql while boot*/
#service postgresql start
No comments:
Post a Comment