I am trying to create a simple bash script. (just started working on bash scripting) the script is simple. There is an issue with rsyslog service and from time to time dies. I am trying to make a script to check if service is dead to restart it till now I want to check if my conditions are ok but it seems I am getting an error. Can you advice me ?
Here is the script:
#!/bin/bash
a="dead"
b="running"
while i in $(/etc/init.d/rsyslog status | grep -o 'running\|dead');
do
if
[ "$a" == "$i" ];
then
echo "service rsyslog is dead "
if
[ "$b" == "$i" ];
then
echo "service rsyslog is running"
else
echo "nothing to do";
fi;
done
-------------
I am getting the following syntax error.
./rsyslogcheck.sh: line 17: syntax error near unexpected token done'
./rsyslogcheck.sh: line 17:done'
Thank you in advance!!
ifis missing itsfi.;) and a newline to separate statements / commands.whileloops withforloops. There is noinoperator inbash;inis just a keyword used to "spell"foreach.