[lug] Script to send apache logs to mysql
John Starkey
jstarkey at advancecreations.com
Sat Jun 9 13:04:45 MDT 2001
Hello again.
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 '\'"
I tried to make the above more readable but pine isn't playing nice.
Sorry.
I'm getting caught up in the quotes. What to escape and what should be
enclosed. I tried exec "mysql .... < ....."; and that still got warped in
the process.
Does anyone know of a way to do this? Or even better yet a mod other than
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.
Thanks,
John
More information about the LUG
mailing list