Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sample Postgresql start/stop script for Cygwin
#!/usr/bin/bash
CYGWIN=server
CYGSERVER=/usr/sbin/cygserver
PGDATA=/var/psql/data
PGCTL=/usr/sbin/pg_ctl
PGLOG=/var/psql/log/postgresql.log
usage() {
echo "USAGE: pg (start|stop|restart|reload|status)"
echo
}
start() {
echo "starting postgresql..."
$CYGSERVER -E & 2>&1
sleep 3
$PGCTL start -D $PGDATA -l $PGLOG
echo
}
stop() {
echo "stopping postgresql..."
$PGCTL stop -D $PGDATA -m smart
$CYGSERVER -S 2>&1
sleep 3
echo
}
restart() {
echo "restarting postgresql..."
$PGCTL restart -D $PGDATA -m smart
echo
}
reload() {
echo "reloading postgresql..."
$PGCTL reload -D $PGDATA
echo
}
status() {
$PGCTL status -D $PGDATA
}
if [ -n "$1" ]
then
case $1 in
start)
start
exit 0
;;
stop)
stop
exit 0
;;
restart)
restart
exit 0
;;
reload)
reload
exit 0
;;
status)
status
exit 0
;;
*)
usage
exit 1
;;
esac
else
usage
exit 1
fi
@buruzaemon
Copy link
Author

buruzaemon commented Apr 10, 2013

Put this script under $HOME/bin, and make sure that $HOME/bin is on your $PATH.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment