Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am having a remote server to which i connect using ssh. I started a process(mongodb) on the server using following command- "/usr/bin/mongod --dbpath /mnt/ebs-300/mongodb --logpath /mnt/ebs-300/log/mongodb/mongodb.log run --config /etc/mongodb.conf &"

As '&' is appended to the command this process runs in the background. After running the process and checking its working properly i exit from the teminal(ssh). This process got killed after some time by printing the below logs - "got kill or ctrl c or hup signal 1 (Hangup), will terminate after current cmd ends"

Can some one please guide me if I am doing wrong or there is proper way to run the process from the remote terminal.


share|improve this question
Did you try with --fork option? – quanta Aug 26 '11 at 8:02
up vote 2 down vote accepted

I would suggest that although '&' runs the command in background, when you exit your terminal it is still getting sent SIGHUP. You could use the disown command

disown prevents the current shell from sending a HUP signal to each of the given jobs when the current shell terminates a login session.

If job is omitted, the most recently started or stopped background job is used.

share|improve this answer
Thanks Rory for the reply. As I don't know much about linux process I need to clear a doubt that according to you even when i exit the terminal it is still getting SIGHUP which is killing the process. To avoid this you said to use disown that ok, but can i also handle this case by using 'nohup' i.e. i would run the process like _ "nohup /usr/bin/mongod --dbpath /mnt/ebs-300/mongodb --logpath /mnt/ebs-300/log/mongodb/mongodb.log run --config /etc/mongodb.conf > /dev/null &" Will it work ? – user_unknown Aug 26 '11 at 8:01
The '&' should be all you need for a nohup (it is equivalent), but it can still be killed if the terminal exits. – Rory Alsop Aug 26 '11 at 8:10
Aaah ok....Thanks for the guidelines :) – user_unknown Aug 26 '11 at 8:22

Rory's answer is fine, but adding the --fork flag to your mongod invocation will keep it running in the background as well.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.