Is there a way to run processes from rails script/console in the background? I have a onetime lib script that will take two or so days to execute and I want to set this to run in the background.
Something like:
script/console
Then:
>> load 'script.rb' &
In the commandline I'd just do:
$ command &
I did find: http://backgroundrb.rubyforge.org/ but this seemed like overkill for just this onetime task.
I also tried:
$ ruby data_importer2.rb &
This doesn't import the active record stuff though (error: uninitialized constant ActiveRecord)
Thanks!
You can do this with the script runner instead of the console:
./script/runner script.rb &
You could use script/runner, or if you need to run it again at some point, the easiest way would be to wrap it in a rake task.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With