Hi All, I am trying a script out that will startup on one of my servers. i wanted to check for RC 0 and if it didnt check out, exit.
Typo- This is BASH (Redhat)
This isnt working, and this is the best way to do error checking I feel. Heres my erorr
./start: line 25: syntax error near unexpected token `elif'
./start: line 25: ` elif [ $? -eq 0]'
heres that part of the script. Can this be done differently and more efficiently? Thanks in advance.
echo "$NOW Starting process"
if ps ax | grep -v grep | grep $process > /dev/null
then
echo "$NOW service is already running"
else
echo "$NOW service is not running running, starting.."
sudo /opt/path/to/code
echo "$NOW $process service has been started"
elif [ $? -eq 0]
then
echo "$NOW service started successfully!"
else
echo "$NOW service did not properly initialize! Exiting"
exit 1
fi
fi