ASP.NET MVC4 application is running in Debian x64 Linux using Apache and mod_mono
Sometimes site starts to return Duplicate session key errors with http code 5xx and application stops working or it start to return returns request timed out errors.
Only re-starting Apache server fixes this.
How to re-start Apache if site stops working?
I tried to create crontab job which checks site after every 20 minutes using wget according to How to avoid apache to stop responding in MVC application :
wget --timeout=10 --no-verbose --tries=1 -a /var/log/wget.log -O /var/log/wgettulem.html www.mysite.com || /etc/init.d/apache2 restart
However wget returns zero exit code even if page returns 500 error. So this is not working. If site returns 500 http error code, Apache is not restarted.
How to restart Apache automatically if page returns 5xx or 4xx http error code?