Forum Moderators: phranque
First time new topic starter.
I have a web server who doesn't archive the log files so each week I have to download the access log. Being busy, one tends to forget to do this now and then so thought setting up a cronjob was the best way to go about it.
Using MacOS X Jaguar, I found Cronnix to allow me to add in the cron job easily but I'm struggling a wee bit with the syntax for an ftp command.
Each week the log file changes name access-log-1020.gz this week and will be access-log-1027.gz next week so was thinking wild cards?
I'm able to use a one line command to get the current accesslog with:
ftp ftp://user:password@some-domain.com/%2Fvar/log/httpd/archive/some-domain-access-log.1020.gz ; type=I
but won't allow me to wildcard the date in the access log eg some-domain-access-log.*.gz nor using .?.gz
I've come across mget but I'm not sure how to work it so that I'm still only using one line.
Any suggestions?
include this in the beginning of the shell script:
MDATE=`date "+%m/%d"`
Replace your month/day with $MDATE.
ftp ftp://user:password@some-domain.com/%2Fvar/log/httpd/archive/some-domain-access-log.$MDATE.gz ; type=I
As long as the cron job runs on the day the log is generated, it should pull the correct file down.
I see that cron (via Cronnix) does allow processing of shell scripts which then eliminates the need for one line and also means I should be able to use mget somehow.
I now have a couple of options - 1. Contact the web server and see if they will tell me their routine - therefore running the cronjob (shell script) on that particular day of the week with the MDATE as the date given or
use figure out how to use mget since I can now run ftp commands one by one with the shell script.
Thanks sun818!
#! /bin/sh
ftp ftp://user:login@some-domain.com
binary
prompt
cd /var/log/httpd/archive
mget some-domain-access-log.*.gz
bye
This will login ok and it changes to binary but not because of my command, its like its not receiving the next command as witnessed when I exit via 'bye'
./accesscron: binary: command not found
./accesscron: prompt: command not found
./accesscron: cd: /var/log/httpd/archive: No such file or directory
./accesscron: mget: command not found
./accesscron: bye: command not found
yet if I use these same commands one by one in the terminal myself it does work?
Well mostly, I have this warning:
ftp> mget some-domain-access-log.*.gz
'EPSV': command not understood.
but it still ftps the access log
Any further help?