Skip to content

Instantly share code, notes, and snippets.

@buruzaemon
Last active February 27, 2019 17:08
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save buruzaemon/5351379 to your computer and use it in GitHub Desktop.
Save buruzaemon/5351379 to your computer and use it in GitHub Desktop.
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

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