title: How to evaluate http response codes from bash/shell script?
body: <p>I have the feeling that I'm missing the obvious, but have not succeeded with <code>man [curl|wget]</code> or google ("http" makes such a bad search term). I'm looking for a quick&amp;dirty fix to one of our webservers that frequently fails, returning status code 500 with an error message. Once this happens, it needs to be restarted.</p>
  
  <p>As the root cause seems to be hard to find, we're aiming for a quick fix, hoping that it will be enough to bridge the time until we can really fix it (the service doesn't need high availability)</p>
  
  <p>The proposed solution is to create a cron job that runs every 5 minutes, checking <a href="http://localhost:8080/" rel="noreferrer">http://localhost:8080/</a>. If this returns with status code 500, the webserver will be restarted. The server will restart in under a minute, so there's no need to check for restarts already running.</p>
  
  <p>The server in question is a ubuntu 8.04 minimal installation with just enough packages installed to run what it currently needs. There is no hard requirement to do the task in bash, but I'd like it to run in such a minimal environment without installing any more interpreters. </p>
  
  <p>(I'm sufficiently familiar with scripting that the command/options to assign the http status code to an environment variable would be enough - this is what I've looked for and could not find.)</p>