log file

A Linux shell script (and commands) to find large files

I made a mistake in configuring logrotate on a new Linux system, and almost ran into a problem because of that. Fortunately I saw the problem before it became a BIG problem, but as a result, I decided to add a script to my Linux system to check for large files, typically log files that have grown out of control for one reason or another.

Here then is a simple Linux shell script I named LargeFileCheck.sh, which searches the filesystem for files that are larger than 1GB in size:

CakePHP log output (Where is it?)

CakePHP log file output FAQ: Help, where is my CakePHP log output? I can't find my CakePHP error log output or my CakePHP debug log output.

If you're writing CakePHP log file output as shown in either of these two methods:

CakeLog::write('debug', 'Where is this message going?');
$this->log($this->data, 'debug');

but can't find this CakePHP log output in your Apache log files or PHP log files, fear not, it's somewhere else. That location is:

A Log4J format example

Log4J formatting FAQ: Can you share a Log4J output/logging format example?

Sure. I'll share a Java Log4J format example that I'm pretty happy with.

I've used the following Log4J logging format quite a bit lately, as I've been working on a headless Java app that can be deployed on thousands of computers, and I was looking for a good Log4J format that was easily readable by humans, and also easy to parse by computers. Here's what my Log4J output format look like these days:

How to save the output from a MySQL query to a file

I had a problem with this website last Wednesday, and as part of troubleshooting the problem, I need to look at one of the Drupal database tables, specifically the watchdog table. This table had thousands of records in it, and I couldn't find what I needed with SQL SELECT queries, so I finally dug through the MySQL documentation, and found that I could save the output from a SELECT query to a text file.

In this tutorial I'll show you both (a) how to save the results of a MySQL query to a text file, and also (b) how to log your entire MySQL session to a text file.

Nagios error code 127, make sure your plugin actually exists alvin August 2, 2008 - 6:01pm

Nagios FAQ: I'm trying to get Nagios to work, but when it starts running there is an error message in the log file that says something like "Nagios, Error Code 127, Make sure the plugin you're trying to run actually exists". How I can fix this?

A Linux find, mtime, exec ls, and sort command

It looked like one of our servers was getting hit pretty hard a while ago, and since we have about 100 sites on that server, I needed a way to find the largest log file. How to solve this? The Linux find command!

First, cd to your apache log file directory. Next, here's the command that showed me the access log files on our system, sorted in ascending order by size:

find . -name "access*" -mtime -1 -exec ls -ld {} \; | sort +4n

Ahh, brings tears of joy to my eye just looking at it. :)