Super User is a question and answer site for computer enthusiasts and power users. 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
pid = `ps -ef | grep -v grep | grep rake | awk '{print $2}'`

This is a bunch of ruby code that executes piped linux commands. While I usually just use ps aux, just because, I noticed that the rake task it finds outputs the path like so:

deployer 10149   1  0 Apr11 ?    00:01:08 /home/dude/.rvm/gems/ruby-1.9.3-p194/bin/rake 

If this rake task was ran from inside a bash script with:

RAILS_ENV=production bundle exec rake qc:work &

Is there a way to find qc:work or some kind of identifier, just in case i run more than one rake task in the future? Maybe ps isn't what is needed, since I run with the &... although I tried bg with no luck.

share|improve this question
Are you sure it is being run? It should show up in ps. What you have posted would not run the command in bash, you would need to have it inside inverted commas or $(). – terdon Apr 13 '13 at 14:56
that is a ruby example of how to run bash code. pid = ... all that is in a rake task in ruby. But yes, even pasting the code into shell inside those inverted quotes works and finds the rake task and pid. – pjammer Apr 14 '13 at 12:46
Inside the inverted commas yes, I am saying that this RAILS_ENV=production bundle exec rake qc:work & won't launch the code, it will just set the variable. – terdon Apr 14 '13 at 12:52

You must log in to answer this question.

Browse other questions tagged .