#!/bin/sh
# Script used for kill of hanging firefox processes

firefox=$(ps -ef | grep firefox -c)
gecko=$(ps -ef | grep gecko -c)
sum=$((firefox + gecko))
echo ""
#if [ $(ps -ef | grep firefox -c) -gt 15 ]
if [ $sum -gt 15 ]
then
   echo "Number of firefox & gecko processes are more than 15(" $sum "), killing all processes!"
   sleep 2
   $(pkill firefox)
   sleep 2
   $(pkill geckodriver)
   sleep 2
#   echo "Number of firefox processes are now: " $(ps -ef | grep firefox -c)
else
   echo "Number of firefox & gecko processes are less than 15(" $sum "), no action taken"
fi

echo ""
