Reputation: 151
I am using a shell script which need to enhaunce.
here is my script structure:
if [ condition 1 ]
statement;
exit;
else if [ condition 2 ]
statement;
exit;
else
sleep 30
fi
I want to modify this script in such a way that if condition 2 is false it will go to else and wait for some time for condition 2 to become true and try it again after 30 seconds. This process should run 5 times. if still condtion 2 is false script should be exited.
Thanks
Upvotes: 0
Views: 102
Reputation: 4714
shell script below maybe works as you desire
#!/bin/sh
if [ condition 1 ]
statement;
exit;
fi
i=1
while [ $i -lt 5 ]
do
if [ condition 2 ]
statement;
exit;
else
sleep 30
true $(( i++ ))
fi
done
Upvotes: 1