title: A shell script to kill a process, whenever it is found to be running
body: <p>I am trying to write a script (which is always running in the background) to kill a process whenever it is found to be running.</p>
  
  <p>The script always exits after an iteration of the loop. How do i fix this problem?</p>
  
  <p>My script:</p>
  
  <pre>
  #!/bin/bash
  
  PROCESS=`ps A | grep iTunes | grep -v grep`
  
  for i in 'seq 1 $max'
  do
          if [ "$?" -ne "1" ]; then
                  killall iTunes
          fi
  done
  </pre>