mardi 14 avril 2015

How do I count the number of scripts running?


Vote count:

0




We created extensions for Chrome, Firefox and Safari and we want to test our extensions with Selenium. I created a script that will run every 4 hours, but sometimes the tests take more than 4 hours. In this case, I want the script to send me an email and exit. Here is my code:



#!/bin/bash

cd /home/ubuntu/selenium_tests

processes=`pgrep -f /home/ubuntu/scripts/run_daily_selenium_tests.sh 2>/dev/null | wc -l 2>/dev/null`
if (("$processes" > "2")); then
echo "Selenium tests already running." | mail -s "Selenium tests already running - `TZ='Asia/Tel_Aviv' date +"%Y-%m-%d %H:%M:%S"`" <my_email_address>
exit
fi

(run tests)...


The problem is, I want the processes to be equal to 1 if there is only one script running, and 2 if there are two scripts running. But it's equal to 2 if there is only one script running. What is the problem and how can I fix it?



asked 13 secs ago

Uri

128






How do I count the number of scripts running?

Aucun commentaire:

Enregistrer un commentaire