↑ ↓ select, Enter open, Esc close

Count HTTP status codes in the access log

Adjust the values, the command updates live
root@server
awk '{print $9}' /var/www/vhosts/system/example.com/logs/access_ssl_log | sort | uniq -c | sort -rn

Counts all status codes in the log and sorts them by frequency. A high share of 404, 403 or 5xx points to broken links, bots or application errors. Expects the combined log format, where the status code is in column 9.

Note: If text shows up in the output instead of numbers, the log format differs. Look at a single line with head -1 first and adjust the column number.

Also searched as

  • how many 404 and 500 errors are there
  • count http status codes in log
  • analyze response codes access log
  • status code distribution apache

Related one-liners

All in Logs

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.