Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: reading of log files
by DrZaius (Monk) on May 07, 2001 at 19:01 UTC | |
The cron daemon generally runs you script and emails any output to you. First, you need to tell crond about your script. You'd do something like this in /etc/cron.d/backup (you don't have to call it backup -- that is just the filename I chose): Now, in your script, print any errors to STDERR, and die if you have to. This will be mailed to you. cheers. | [reply] [d/l] |
by AidanLee (Chaplain) on May 07, 2001 at 21:30 UTC | |
If you'd rather avoid depending on an outside tool for more than scheduling (I wouldn't reccommend writing a scheduler, most OSes have one), You could look into Mail::Sender for sending out emails. Benefits: -Doesn't require a particular scheduler/ OS, or mail program | [reply] |
|
Re: reading of log files
by mr.nick (Chaplain) on May 07, 2001 at 20:52 UTC | |
| [reply] |
|
Re: reading of log files
by thpfft (Chaplain) on May 08, 2001 at 16:07 UTC | |
Sounds to me like you need logcheck. It's a shell script, usually set up by the admin as an hourly cron job, but also workable in your home space if you have permission to access the logs. it might save you some work. Failing that, here's the bit that will read the file and record anything bad it finds:
Which just leaves you to write the regex that will spot bad news in the file, and a sub to send you $badnews in an email message if it finds any. You should also replace the or die() instructions with something that will send you another sort of message if reading the logfile fails. Bear in mind that there are issues with constantly incremented files: when perl opens the file it will remember the length of it and read only that far unless you resest the EOF flag. It probably doesn't matter, but the cookbook has more information if you need it. Hope this helps. | [reply] [d/l] [select] |
|
Re: reading of log files
by codechuck (Initiate) on May 07, 2001 at 19:13 UTC | |
| [reply] [d/l] |