#!/bin/bash
#
#MailList=saicharan.burle@gmail.com
Distro_server=qtdenvmdt066
apps=/opt/apache/qwest/websites
cd $apps
###### This will print list of all applications into one txt file######
ls > print.txt
for username in `awk -F: '{print $1}' /opt/apache/qwest/websites/print.txt`
do
echo "Username $((i++)) : $username"
#pr=`ps -ef | grep $username|grep -v 'grep'|head -1|cut -d' ' -f6`
pr=`ps auxw | grep $username| grep -v grep | head -1| awk '{print $2}'`
echo " $pr "
if [ $pr > 0 ]
then
echo " $apps has been started successfully
"
else
echo " $apps has not started Please check......." |mailx -s "Health Check for $Distro_server"
saicharan.burle@gmail.com
fi
done
The command worked, I just did some changes, This is the modified script which is working now.....
Please find the output:
Username 1 : aa99036-eap-int1-30101-40086
test.sh: line 21: mailx: command not found
Username 2 : ace-30115-40102
29868
/opt/apache/qwest/websites has been started successfully
Username 3 : ace-voip-30107-40097
3478
/opt/apache/qwest/websites has been started successfully
Username 4 : amrtws-int1-30109-40095
4397
/opt/apache/qwest/websites has been started successfully
Username 5 : aqcb-40015
4774
The only thing left is mailx command