Start/Stop MongoDB Using These Aliases

Just a quick note on working with MongoDB on Linux/Unix.
Recently I needed some ready-made commands to start and stop MongoDB that I could just copy/paste and go, so I created the following aliases for my Bash profile that did the trick. I use these for developing with MongoDB on a MacBook Pro exactly the same way that I make use of aliases for PostgreSQL and MySQL. These are mainly notes for myself for posterity but I'm hopeful that they may also help someone else as well:
# Start up MongoDB using a forked process and log appending
alias mongostart='/var/mongodb/bin/mongod --fork --dbpath /var/mongodb/data/db --logpath /var/mongodb/log/mongodb.log --logappend'
# Shut down MongoDB safely using the soft kill on the PID
alias mongostop="kill -2 `ps aux | grep [m]ongo* | awk '{ print $2 }'`"
Put these in your ~/.bash_profile or ~/.profile, reload the profile and away you go. Obviously you will need to adjust the paths to suit your own environment.
About Bruce Snyder
Bruce Snyder is a veteran of enterprise software development and a recognized leader in open source software. With over a decade of experience, Bruce has worked with a wide range of technologies including Java EE, Enterprise Messaging and Service Oriented Integration. In addition to his role as a senior software engineer at SpringSource, Bruce is also an Apache Member, a co-founder of Apache Geronimo and a developer for Apache ActiveMQ, Apache Camel and Apache ServiceMix. He is the co-author of Professional Apache Geronimo, Beginning Spring Framework 2 both from Wrox Press and is currently co-authoring ActiveMQ In Action for Manning Publications. Bruce also serves as a member of various JCP expert groups and is a recognized international speaker at industry conferences. Bruce lives in beautiful Boulder, Colorado with his family.
More About Bruce »Northern Virginia Software Symposium
November 1 - 3, 2013
Reston, VA
Current Topics on the NFJS Tour
- Core Java, JEE
- Dynamic Languages: Groovy, JRuby, Scala, Clojure
- RESTful Web Apps
- Frameworks: Hibernate, Grails, Spring, JSF, GWT, more
- Agility
- Test Driven Design
- Security
- Ajax, Flex, RIA
Why Attend the NFJS Tour?
- » Cutting-Edge Technologies
- » Agile Practices
- » Peer Exchange
Current Topics:
- Languages on the JVM: Scala, Groovy, Clojure
- Enterprise Java
- Core Java, Java 7
- Agility
- Testing: Geb, Spock, Easyb
- REST
- NoSQL: MongoDB, Cassandra
- Hadoop
- Spring 3
- Automation Tools: Git, Hudson, Sonar
- HTML5, Ajax, jQuery, Usability
- Mobile Applications - iPhone and Android
- More...
NFJS, the Magazine
May Issue Now AvailableOn the road to learning
by Raju GandhiRefactoring to Modularity
by Kirk KnoernschildRESTful Groovy
by Kenneth KousenGetting Started with D3.js
by Brian Sletten