I am running a background rake task. (Using ‘&’). The thing is that I want it to stop sometimes. So I wrote this:
pinger_pid = system "ps | grep rake | awk '{print $1}'"
puts pinger_pid
system "kill -9 #{pinger_pid}"
Seems that I am getting a ‘true’ output garbage! How can I remove that?
output:
ERROR: garbage process ID "true".
Usage:
kill pid ... Send SIGTERM to every process listed.
kill signal pid ... Send a signal to every process listed.
kill -s signal pid ... Send a signal to every process listed.
kill -l List all signal names.
kill -L List all signal names in a nice table.
kill -l signal Convert between signal numbers and names.
System returns true or false, depending on the success of the command.
Use %x to capture output: