If you have a Postgres database and want to ensure that it automatically restarts, this shell script is very helpful, especially for online environments such as C9.
# Startup Postgres server automatically
function checkstart {
service=$1
if [[ ! $(ps -ef | grep -v grep | grep "$service" | wc -l) > 0 ]]
then
sudo service $service start &
fi
}
checkstart postgresql
function checkstart {
service=$1
if [[ ! $(ps -ef | grep -v grep | grep "$service" | wc -l) > 0 ]]
then
sudo service $service start &
fi
}
checkstart postgresql