title: Simple bash script count running processes by name
body: <p>i'm working on a small bash script which counts how often a script with a certain name is running.</p>
  
  <pre><code>ps -ef | grep -v grep | grep scrape_data.php | wc -l
  </code></pre>
  
  <p>is the code i use, via ssh it outputs the number of times scrape_data.php is running. Currently the output is 3 for example. So this works fine.</p>
  
  <p>Now I'm trying to make a little script which does <strong>something</strong> when the count is smaller than 1.</p>
  
  <pre><code>#!/bin/sh
  
  
  if [ ps -ef | grep -v grep | grep scrape_data.php | wc -l ] -lt 1; then
          exit 0
  
   #HERE PUT CODE TO START NEW PROCESS
  
  else
  
          exit 0
  fi
  </code></pre>
  
  <p>The script above is what I have so far, but it does not work. I'm getting this error:</p>
  
  <pre><code>[root@s1 crons]# ./check_data.sh
  ./check_data.sh: line 4: [: missing `]'
  wc: invalid option -- e
  </code></pre>
  
  <p>What am I doing wrong in the if statement?</p>