[lug] Script to send apache logs to mysql

Evelyn Mitchell efm at tummy.com
Sun Jun 10 10:53:43 MDT 2001


> I'm trying to set up a nightly cron to send my apache logs to MySQL. I've
> got the commands working fine but I can't come up with the way to execute
> it as a shell script. Can someone help?
> 
> #!/bin/bash
> 
> /usr/bin/mysql -u user -p pazzword Apache <
>  "LOAD DATA INFILE '/path/to/apache/logs/mysql_format_log'
>  INTO TABLE access_log FIELDS TERMINATED BY ','  OPTIONALLY ENCLOSED BY
> '"' ESCAPED BY '\'"
> 
Try:

#!/bin/bash
 
/usr/bin/mysql -u user -p pazzword Apache <
 "LOAD DATA INFILE '/path/to/apache/logs/mysql_format_log'
  INTO TABLE access_log FIELDS TERMINATED BY ','  OPTIONALLY ENCLOSED BY
 '\"' ESCAPED BY '''' "

http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html

I haven't tested that this works with mysql, but it errors in the 'right'
way in bash (No such file or directory).

> mod_log_mysql that does this now? 3 hours of google turned up only that
> which I can't find an update for since 98. Apache has moved all their
> headers around since and I can get to all but one. Can't find it anywhere.
> os.h I believe.

http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html

Regards,
Evelyn Mitchell
efm at tummy.com




More information about the LUG mailing list