Apache with Linux

Here is a simple script that reads the last complete access log file, filter lines containing google, compress the file and send it to OnCrawl FTP.
One need to replace the FTP_* variables with real values.
Once the setup is in place, the execution can be automated once a day using the cron.

#!/bin/bash

FTP_SERVER='ftp.oncrawl.com'
FTP_USER='<LOGIN>'
FTP_PASS='<PASS>'
FTP_FOLDER=‘<PROJECT DIRECTORY>’
#Get the previous *complete* access file
LOG_FILENAME=‘/var/log/apache2/access.log.1’
GREP_WORD='google'
LOG_TMP_FILE="/tmp/access.log-$(date +%Y-%m-%d).${GREP_WORD}_only.gz"

grep $GREP_WORD $LOG_FILENAME | gzip > $LOG_TMP_FILE

curl -s -T $LOG_TMP_FILE ftp://${FTP_SERVER}/${FTP_FOLDER} --user $FTP_USER:$FTP_PASS

rm $LOG_TMP_FILE

Did this answer your question?