we have a request to execute multiple shell scripts(scripts that starts application servers) in a sequential manner
The real bet is we have to verify the process(pid) is up or not before proceeding to next script. if no process is running then display an error message and continue with next script
Also send an consolidate email with error (which script got failed) after completion of executing(running) all scripts
Note: These services are not dependent its just that we are checking the the status after each script
Below is what i came up with...please Help
#!/bin/bash
./script1.sh
PID=`ps -ef | grep c3f | grep -v grep | awk '{print $2}' | wc -l`
if [ $PID -ne 0 ]; then
echo "error pls check";
fi
./script2.sh
PID1=`ps -ef | grep d3f | grep -v grep | awk '{print $2}' | wc -l`
if [ $PID1 -ne 0 ]; then
echo "error pls check";
fi
./script3.sh
PID2=`ps -ef | grep E3f | grep -v grep | awk '{print $2}' | wc -l`
if [ $PID2 -ne 0 ]; then
echo "error pls check";
fi