1

I have a line:

RAILS_ENV=production bundle exec rake mentions:stream > mention.log

It outputs text to the mention.log file.

When I try to run it as background job:

RAILS_ENV=production bundle exec rake mentions:stream > mention.log &

it does not output anything to this file.

Can someone explain me why?

1
  • 1
    If you're running both commands in the same environment/shell and the only difference is the & at the end of the background version then I don't see why it wouldn't work unless the bundle command is expecting to read input from the terminal. Do you get any output when you invoke the background version? Does the command complete? What do you see if you run jobs in the same shell? – Paul Haldane Oct 7 '16 at 15:55
0

Can you try running with the following

RAILS_ENV=nohup production bundle exec rake mentions:stream > mention.log 2>&1 &

I have also added 2>&1 & so that it will also output STDERR into your log file should there be any errors and also nohup at the beginning of your line.

5
  • file containts "production: command not found" – Marcin Doliwa Oct 7 '16 at 15:02
  • Ah I see. Try adding the nohup before "rake" as I believe this is the application executed? Also remove exec because we use nohup. – SleepyMan Oct 7 '16 at 15:06
  • This time I get "nohup: ignoring input" only – Marcin Doliwa Oct 7 '16 at 15:09
  • I have updated my last comment as I think it was incorrect and you wouldn't need to use exec I believe as we use nohup. – SleepyMan Oct 7 '16 at 15:09
  • This time I get "Could not find command "nohup"" – Marcin Doliwa Oct 7 '16 at 15:11

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