title: cpulimit of a given process
body: <p>I'm running the windows version of Tribler using wine in Ubuntu 10.10. Some times it eats a lot of power of my cpu and causes my laptop to heat up. So I need to slowdown Tribler, and I discovered <code>cpulimit</code>. To run <code>cpulimit</code> you need to use the <code>PID</code> number of the process. So I managed to do the following in <code>.bashrc</code>:</p>
  
  <pre><code>alias tribler='wine /home/my_home/.wine/drive_c/Program\ Files/Tribler/tribler.exe'
  alias slowdowntribler="cpulimit -l 10 -p `ps -ef | grep 'tribler.exe' | grep -vw 'grep' | awk '{print $2}'`"
  alias slowtribler='tribler; slowdowntribler'
  </code></pre>
  
  <p>The alias <code>tribler</code> just run the windows version of Tribler using <code>wine</code>.
  The alias <code>slowdowntribler</code> just run <code>cpulimit</code> using the <code>PID</code> of the process whose name is <code>Tribler.exe</code>.</p>
  
  <p>It is assumed that the third alias first run <code>tribler</code> so <code>Tribler.exe</code> goes up, and then <code>slowdowntribler</code> to limit the cpu usage of Tribler. But a problem arises here. This last alias will run <code>slowdowntribler</code> after I quit (or kill) <code>Tribler.exe</code>. To solve this I have tried:</p>
  
  <pre><code>alias slowtribler='tribler&amp;; slowdowntribler'
  </code></pre>
  
  <p>(and some variations) but I get the following error:</p>
  
  <blockquote>
    <p>bash: syntax error near unexpected token `;'</p>
  </blockquote>
  
  <p>I don't know how to proceed.</p>