Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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 have a sinatra app which I run on my local machine using ruby app.rb.

While deploying it on a remote machine via ssh, How do i run it in background and redirect stdout and stderr to a log file. On a restart, I want to preserve the previous logs so that newer messages are appended to the existing log file, instead of truncating it.

What's the recommended way of running my webapp as a daemon ?

I've tried nohup ruby app.rb & , but that seems to be missing stderr and the log statements seem to be out of order in some cases.

share|improve this question
up vote 7 down vote accepted

Under bash, try:

nohup ruby app.rb >> /log/file 2>&1 &
share|improve this answer
"2>&1" what does that mean ? – letronje Dec 20 '10 at 6:27
"Send STDERR to the same place you're sending STDOUT" – MadHatter Dec 20 '10 at 6:56
thnx a ton for the cmd :) – letronje Dec 20 '10 at 12:13
you're welcome. – MadHatter Dec 20 '10 at 18:37
And what does the end & mean? – Nakilon Oct 10 '13 at 16:57

screen -L -dmS somename ruby app.rb

This will start a screen process with the name of 'somename', with all output from the program being logged to screenlog.0 in the current working directory.

If you ever want to get back the application's console for some reason, you can do screen -r somename.

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.