jeffci
jeffci

Reputation: 2622

Background tasks and shell commands from a Rails app

I am looking to frequently create 3 background tasks and execute some shell commands from these tasks from my Rails app. I was thinking about using delayed_job for the background tasks but I am unsure as to how to safely execute shell commands from a rails app, can someone tell me how I can do this from a Rails app?

Jeff

Upvotes: 1

Views: 1307

Answers (1)

RadBrad
RadBrad

Reputation: 7304

There are several ways, all are Rubyisms.

system('cmd','arg1',...)

Or the very Unixy

val = `ls -l`

The latter would run the command and return it's output into the variable val.

Upvotes: 4

Related Questions