# Rake background task can not run

**URL:** <https://www.ruby-forum.com/t/rake-background-task-can-not-run/194474>\
**Category:** Rails\
**Created:** [September 6, 2010, 4:39pm UTC](https://www.ruby-forum.com/t/rake-background-task-can-not-run/194474 "2010-09-06T16:39:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![boblu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b19c9b/32.png) [@boblu](https://www.ruby-forum.com/u/boblu)\
**Post date:** [September 6, 2010, 4:39pm UTC](https://www.ruby-forum.com/t/rake-background-task-can-not-run/194474/1 "2010-09-06T16:39:39Z")

</div>

I want to use rake background task in rails like this

system(“cd #{Rails.root} && RAILS\_ENV=#{Rails.env} rake abc:def –  
trace 2\>&1 \>\> #{Rails.root}/log/rake.log &”)

This is ok in development environment, but will not work in production  
mode.

I used logger to check whether the command string is generated ok or  
not, but it seems every things is fine in production evironment:

cd /home/username/rails\_staging/Abc/releases/20100904034630 &&  
RAILS\_ENV=production rake abc:def --trace 2\>&1 \>\> /home/username/  
rails\_staging/Abc/releases/20100904034630/log/rake.log &

Any body has any ideas about why this can not work in production mode?

Thanks

---

<div class="post-metadata">

**Author:** ![boblu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b19c9b/32.png) [@boblu](https://www.ruby-forum.com/u/boblu)\
**Post date:** [September 6, 2010, 4:39pm UTC](https://www.ruby-forum.com/t/rake-background-task-can-not-run/194474/2 "2010-09-06T16:39:53Z")

</div>

On Sep 4, 5:38 am, boblu [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I want to use rake background task in rails like this
> 
> system(“cd #{Rails.root} && RAILS\_ENV=#{Rails.env} rake abc:def –  
> trace 2\>&1 \>\> #{Rails.root}/log/rake.log &”)
> 
> This is ok in development environment, but will not work in production  
> mode.

What happens?

Fred

---

<div class="post-metadata">

**Author:** ![boblu](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b19c9b/32.png) [@boblu](https://www.ruby-forum.com/u/boblu)\
**Post date:** [September 6, 2010, 4:44pm UTC](https://www.ruby-forum.com/t/rake-background-task-can-not-run/194474/3 "2010-09-06T16:44:09Z")

</div>

My first suspicion would be that you need the full path to rake…  
but no promises 🙂

On Sep 4, 5:36 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
