Re: [PHP] Friday morning brain farts....
- From: stuttle@xxxxxxxxx (Stut)
- Date: Fri, 10 Aug 2007 17:39:36 +0100
Robert Cummings wrote:
On Fri, 2007-08-10 at 11:48 -0400, Daniel Brown wrote:On 8/10/07, Stut <stuttle@xxxxxxxxx> wrote:.... I get an email from eachThat's actually a good point there that I can take away from this.
server containing the contents of the error log from the previous day
and my first task each day is to go through that and track down any
issues that usage has highlighted.
I actually don't have anything set to send me a log of code issues,
only when an error is caused (and, of course, anything server-related,
but that's a different point entirely).
Simple enough... put the following in a file, and add a cron job.
#!/usr/bin/php -qC
<?php
if( !isset( $argv[1] ) || !isset( $argv[2] ) || !isset( $argv[3] ) )
{
echo "Usage: {$argv[0]} <subject> <email> <path>\n";
exit( 1 );
}
$subject = $argv[1];
$email = $argv[2];
$path = $argv[3];
$content = implode( '', file( $path ) );
if( trim( $content ) === '' )
{
$content = 'NO ERRORS TODAY!!!';
}
mail( $email, $subject, $content );
?>
I used to have something similar to this until someone uploaded a script that started writing to the error log like mad. Overnight my poor little script tried to load a 240meg log file into memory and email it to me. I now use a simple bash script that pipes the log to the mail command - much safer.
Should probably say that it also renames the log file, graceful's Apache, zips the old log and moves it to an archive file server. Rob's script above, used without something that starts a new log will result in ever-increasing emails.
-Stut
--
http://stut.net/
.
- Follow-Ups:
- Re: [PHP] Friday morning brain farts....
- From: "Michael Preslar"
- Re: [PHP] Friday morning brain farts....
- From: Robert Cummings
- Re: [PHP] Friday morning brain farts....
- References:
- Friday morning brain farts....
- From: Jason Pruim
- Re: [PHP] Friday morning brain farts....
- From: "Daniel Brown"
- Re: [PHP] Friday morning brain farts....
- From: Stut
- Re: [PHP] Friday morning brain farts....
- From: "Daniel Brown"
- Re: [PHP] Friday morning brain farts....
- From: Robert Cummings
- Re: [PHP] Friday morning brain farts....
- From: "Daniel Brown"
- Re: [PHP] Friday morning brain farts....
- From: Stut
- Re: [PHP] Friday morning brain farts....
- From: "Daniel Brown"
- Re: [PHP] Friday morning brain farts....
- From: Stut
- Re: [PHP] Friday morning brain farts....
- From: "Daniel Brown"
- Re: [PHP] Friday morning brain farts....
- From: Robert Cummings
- Friday morning brain farts....
- Prev by Date: Re[2]: [PHP] Friday morning brain farts....
- Next by Date: Re: [PHP] Recursion and threaded message boards...
- Previous by thread: Re: [PHP] Friday morning brain farts....
- Next by thread: Re: [PHP] Friday morning brain farts....
- Index(es):