I'm creating a bash script in which whenever my apache exceeds a fixed amount of numbers then it restart itself on next cronjob. I've created something but it is not running properly.
#!/bin/bash
RESTART="systemctl restart httpd"
COUNT="ps aux | grep httpd | wc -l"
SERVICE="httpd"
LOGFILE="/opt/httpd/autostart-apache2.log"
if COUNT > 45
then
echo "starting apache at $(date)" >> $LOGFILE
$RESTART >> $LOGFILE
else
echo "apache is running at $(date)"
fi
The error it is throwing is
line 10: COUNT: command not found
apache is running at Sat Sep 10 23:34:30 IST 2022
Can anyone help me on how to store the value of the output of ps aux | grep httpd | wc -l as a number and compare it with another number.