linux执行pgsqlsql脚本,postgresql linux启动脚本

[root@test pgsql]# more /etc/init.d/postgresql

#! /bin/sh

# chkconfig: 2345 98 02

# description: PostgreSQL RDBMS

# This is an example of a start/stop script for SysV-style init, such

# as is used on Linux systems.  You should edit some of the variables

# and maybe the 'echo' commands.

#

# Place this file at /etc/init.d/postgresql (or

# /etc/rc.d/init.d/postgresql) and make symlinks to

#   /etc/rc.d/rc0.d/K02postgresql

#   /etc/rc.d/rc1.d/K02postgresql

#   /etc/rc.d/rc2.d/K02postgresql

#   /etc/rc.d/rc3.d/S98postgresql

#   /etc/rc.d/rc4.d/S98postgresql

#   /etc/rc.d/rc5.d/S98postgresql

# Or, if you have chkconfig, simply:

# chkconfig --add postgresql

#

# Proper init scripts on Linux systems normally require setting lock

# and pid files under /var/run as well as reacting to network

# settings, so you should treat this with care.

# Original author:  Ryan Kirkpatrick # $PostgreSQL: pgsql/contrib/start-scripts/linux,v 1.8 2006/07/13 14:44:33 petere Exp $

## EDIT FROM HERE

# Installation prefix

prefix=/usr/local/pgsql

# Data directory

PGDATA="/usr/local/pgsql/data"

# Who to run the postmaster as, usually "postgres".  (NOT "root")

PGUSER=postgres

# Where to keep a log file

PGLOG="$PGDATA/serverlog"

## STOP EDITING HERE

# The path that is to be used for the script

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# What to use to start up the postmaster (we do NOT use pg_ctl for this,

# as it adds no value and can cause the postmaster to misrecognize a stale

# lock file)

DAEMON="$prefix/bin/postmaster"

# What to use to shut down the postmaster

PGCTL="$prefix/bin/pg_ctl"

set -e

# Only start if we can find the postmaster.

test -x $DAEMON || exit 0

# Parse command line parameters.

case $1 in

start)

echo -n "Starting PostgreSQL: "

su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1

echo "ok"

;;

stop)

echo -n "Stopping PostgreSQL: "

su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast"

echo "ok"

;;

restart)

echo -n "Restarting PostgreSQL: "

su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w"

su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1

echo "ok"

;;

reload)

echo -n "Reload PostgreSQL: "

su - $PGUSER -c "$PGCTL reload -D '$PGDATA' -s"

echo "ok"

;;

status)

su - $PGUSER -c "$PGCTL status -D '$PGDATA'"

;;

*)

# Print help

echo "Usage: $0 {start|stop|restart|reload|status}" 1>&2

exit 1

;;

esac

exit 0

阅读(1942) | 评论(0) | 转发(0) |

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值