Web Hosting Talk







View Full Version : CRON JOB for emailing logs


GTOTYPE
10-01-2001, 11:09 AM
Hi is it possible to have a cron job to email you your raw log files to your email everyday at a certain time? If so can anyone help me to create one or tell me how to?

Thanks in advance.

ffeingol
10-01-2001, 12:45 PM
Well assuming you're on a linux box, something like this would do it:

cat /path/to/log_file | mail -s "da log" email@yourdomain.tld

but I doubt that is what you really want. I'm assuming you want it as an attachment? In that case, you'll need to create a mime e-mail message (a bit more difficult).

Why would you want raw logs mailed to you? Which logs BTW?

Frank

RutRow
10-01-2001, 10:58 PM
You might want to look at Logcheck.

http://www.psionic.com/abacus/logcheck

It will email you information from your log files and it keeps a running track of where it left off.

ffeingol
10-01-2001, 11:27 PM
Yep, logcheck is great. You just have to play with the files for a while to include/exclude exactly what you want.

Frank

GTOTYPE
10-01-2001, 11:47 PM
How about something like this.....

The info on the log lets say

/usr/local/apache/domlog/domain.log

being sent to a email address... It doesn't neccessarily have to be a attackment, the information is important.

ffeingol
10-02-2001, 06:36 AM
You have not said what os you are running under. I'm going to assume it's Red Hat linux.

If you want this to run daily, you could put the following script into /etc/cron.daily:


#! /bin/sh

/bin/cat /usr/local/apache/domlog/domain.log | /bin/mail -s "Apache log file" email-address@your-domain.tld


Make sure to chmod the script to something like 700

But this is going to e-mail the whole Apache log to you every day. If you have a busy server, your Apache log will get huge and you'll be sending yourself a huge mail message.

Frank

GTOTYPE
10-02-2001, 02:24 PM
Its redhat linux 6.2,

I just want the logs for a certain domain... not the apache log :bawling:

dektong
10-02-2001, 02:45 PM
Why would I want to have apache log be mailed to me everyday? One of my clients has his apache log grows at about 25-30MB per day (oh my gosh, after 5 months of hosting him I have about 4GB worth of apache log already! :eek: Good thing we have gzip :) ), I am pretty sure he does not want the apache log be sent to him :)

cheers,
:beer:

ffeingol
10-02-2001, 02:50 PM
Well that was my point too :D

What is it that you want to do with the log? There are very good (free) log analysis tools available on Linux.

Depending on how Apache is configured it will be easy/impossible to get the logs for 1 domain. By default, I believe Apache puts all the logs for all the virtual servers into one log file (/logs/access_log in your Apache install directory). That would be difficult to split apart. OTOH, you can also configure Apache to put each virtual domain into their own log file.

This is not really answering your quesiton, but maybe it will get things pointed in the right direction.

Frank

Synergy
10-02-2001, 06:18 PM
Cpanel lets you download the log for a your account. So how do you do that vice versa by sending a log to a certain email for a certain domain?