Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

How to let the admin get noticed when 500 errors occurred in nginx?

share|improve this question
Just for some attempted clarification. Do you want to setup an alert to the admin (you, presumably) if the number of errors on your webserver reaches a certain threshold, in this case 500? –  LukeR Jan 21 '10 at 5:21
Yes, that's what I mean. –  Cheng Jan 21 '10 at 9:59
I use a commercial service at wormly.com –  Vasili Syrakis May 22 '14 at 5:20

3 Answers 3

up vote 2 down vote accepted

maybe you could do something with a bash script, like


b=`grep 'error' -c /var/log/nginx.log`

if [[ $b -gt 500 ]] ; then
echo "more than 500 errors";
# or send an email

#echo "OK" > /dev/null 2>&1

share|improve this answer
shouldn't it be if [[ $b > 500 ]]? –  einstiien Jan 21 '10 at 14:53
yah my bad, I'll fix it thanks :) –  Razique Jan 21 '10 at 16:08
[[ does not support comparison using >; you need either -gt/-lt or (( )). See mywiki.wooledge.org/BashPitfalls#A.5B.5B_.24foo_.3E_7_.5D.5D –  grawity Jan 22 '10 at 14:26
Hi grawity, thanks for the fix, I updated the script :) –  Razique Jan 26 '10 at 8:08

Most monitoring systems, whether they're software you install like Nagios or Zabbix or monitoring services such as Panopta or Pingdom, can be configured to detect 500 responses as errors and alert you to investigate. The benefit of using a full monitoring system is that you can get SMS or voice alerts in addition to just emails. You can also get notified if the server itself goes down or loses all connectivity, which a local cron script wouldn't be able to handle.

share|improve this answer

No matter you use scripts or monitoring systems. You can used "curl" to check the http status code.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.