Checking All Logs Using A For Loop

In this post I will be showing you how to check your log files for errors. Your log files should be located in the /var/log/ directory. We will be using vague search terms such as error and fail so keep in mind that just because you get a result doesn’t mean you actually have a problem, there will almost always be some noise in the results.

If you want to check all your logs for certain search strings you can do so by running the following either directly in your terminal or by saving it as a script and running it, don’t forget to modify the grep piece of the loop to what you are searching for.

Check All Logs In Linux

Checking Single Logs

In this example we will take a look at the DMESG log. You have 2 options for checking DMESG, you can run the dmesg command or you can look in /var/log/dmesg. In the example below I will run the dmesg command and pipe the output into grep for 2 different search terms.

Search DMESG for errors

I hope you enjoyed this quick and to the point post, please don’t forget to like/comment/share! =)

Leave a Reply

Your email address will not be published. Required fields are marked *