I would like to restart the apache server, when it's down. Hence I wrote a script below using curl and an if loop
curl example.com
si='curl example.com'
if test si !=0
then
service apache2 restart
fi
~
I expect to restart apache server, if the site is down
But It returns the following error
curl: (7) Failed to connect to example.com port 80: Connection refused
autostart.sh: line 8: test: si: unary operator expected