Skip to content

Instantly share code, notes, and snippets.

@physacco
Created April 17, 2013 08:42
Show Gist options
  • Select an option

  • Save physacco/5402785 to your computer and use it in GitHub Desktop.

Select an option

Save physacco/5402785 to your computer and use it in GitHub Desktop.
Scripts used to start/stop/check postgresql. (2010)
#!/bin/sh
PidFile=/usr/local/pgsql/data/postmaster.pid
foo()
{
if [ -f "$PidFile" ]; then
pgrep postgres | grep `head -1 $PidFile`
fi
}
Pid=`foo`
if [ -z "$Pid" ]; then
echo "postgres is stopped."
else
echo "postgres ($Pid) is running."
fi
#!/bin/sh
su -c '/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data -k /var/run/postgresql >/usr/local/pgsql/var/log/postgres.log 2>&1 &' postgres
#!/bin/sh
kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment