Why bother remembering very long commands?

There is a shell script for automatically starting, stopping and restarting PostgreSQL if you have installed PostgreSQL on /usr/local. In fact there is a shell script for nearly every redundant task for developers and Linux system administrators (even spammers).

See the following guide first:

PostgreSQL on Mac OS X

The shell script:


#!/bin/bash

start()
{
        echo -n "Starting PostgreSQL server"
        sudo su postgres -c '/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data/ -l /usr/local/pgsql/data/postgresql.log start'

        return
}

stop()
{
        echo -n "Stopping PostgreSQL server"
        sudo su postgres -c '/usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data/ stop'
        return
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        stop
        start
        ;;
    *)
        echo "Usage: {start|stop|restart}"
        exit 1
        ;;
esac

Usage: /path/to/script start (stop|restart).

You can create aliases on .bash_profile to make the command shorter.

A good friend also has a very nice post for Mac OS users who are also Ruby programmers. I am not sure if we all have the same preferences. Do we use Firefox and Firebug that often? Chrome is worth trying, right? Do we use MongoDB for Rails apps? You can rework his script according to your needs. Check out the post of Radamanthus Batnag on how to automatically start applications you need to get ready for "work mode."

comments powered byDisqus

Hello! I am Kat. I've been a developer for several years. When I'm not sitting down, reading and working for long hours, I am traveling to some place of interest.
If you want to reach out, you can send me an email or add me up on Google Plus.