I am working on a small bash script that counts how often a script with a specific name works.
ps -ef | grep -v grep | grep scrape_data.php | wc -l
- this is the code that I use, through ssh it displays the number of scrape_data.php starts. Currently, the output is, for example, 3. So this works great.
Now I am trying to make a little script that does something when the amount is less than 1.
#!/bin/sh
if [ ps -ef | grep -v grep | grep scrape_data.php | wc -l ] -lt 1; then
exit 0
else
exit 0
fi
The script above is what I have so far, but it does not work. I get this error:
[root@s1 crons]
./check_data.sh: line 4: [: missing `]'
wc: invalid option -- e
What am I doing wrong in an if statement?
source
share