Skip to content

Instantly share code, notes, and snippets.

@posulliv
Created May 3, 2009 05:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save posulliv/105856 to your computer and use it in GitHub Desktop.
Save posulliv/105856 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $# -ne 1 ]
then
echo "Incorrect number of arguments"
echo "Usage"
echo "./script ROOT_DIR_OF_POSTGRES_INSTALL"
exit 1
fi
bin_dir=$1
if [ ! -d ${bin_dir} ]
then
echo "PostgreSQL installation directory does not exist!"
exit 1
fi
proc=`ps -ef | \
grep postgres: | \
grep -v -e 'grep postgres:' \
-e 'postgres: stats' \
-e 'postgres: wal' \
-e 'postgres: archiver' \
-e 'postgres: logger' \
-e 'postgres: autovacuum' \
-e 'postgres: writer' | \
tee /dev/tty | \
awk '{print $2}'`
if [ `echo "$proc" | wc -w` -eq 1 ]
then
exec gdb ${bin_dir}/bin/postgres -silent "$proc"
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment