Web Hosting Talk







View Full Version : Question on log files


Kaith Sutai-Rustaz
02-07-2001, 01:04 PM
'Allo. Have a bit of a challenge with log files. I'd like to be able to have things set up so that at a regular interval, the server would take the current access and error log, compress it (gzip) and dump it into a \logs directory on my site, then reset the logs. I've seen a few hosts that offer this, but so far am having no luck figuring out how to do it on my current host. (Burst/US when asked said yes you may...new host currently being sought.) Basic specs are I believe a RH 6.2, with CPanel. I tried hunting around the server thru telnet, but every spot that -should- have logs in it only has empty files, and I can't locate the file that the cpanel wants to ftp to me.

Since I've been informed that this particular server config dumps the logs every month to save space and I really prefer to do my own log analysis I'm kinda in a bind.

Help, Hints greatly apreciated.

Thanks!

kunal
02-07-2001, 04:21 PM
Couldnt you do this with a simple cron Script?

Kaith Sutai-Rustaz
02-07-2001, 04:48 PM
We could. 2 problems:

1- No clue how to write the script. My guess would be something like "gzip source destination" but....

2- No idea where the log files in question are as -every- spot I checked on the server had empty log files, and I couldn't find the file or directory that the CPANEL shows when I click on (download raw log file)

I'm lost.

allan
02-07-2001, 05:09 PM
Find out from your provider where the log files are located, and I can give you a sample shell script that will do it for you :).

Kaith Sutai-Rustaz
02-07-2001, 05:25 PM
Ok, we got the info on where the current logs are kept. Can you email the script? Tis greately apreciated!

(also, is this for servers or domains? all of our current accts are resolds at the moment, but we are looking at going dedicated shortly.)

Thanks!

allan
02-08-2001, 12:42 AM
Here's the link to the script:

http://www.scriptsolutions.com/programs/free/backmeup/index.html

All you need to do is create a cron job that does the backup as often as you want.

You can read more about writing cron jobs here:

http://www.unm.edu/cgi-bin/man-cgi?crontab

Of course, since you are running on Linux, you can just put the script right in:

/etc/cron.half-hourly
/etc/cron.hourly
/etc/cron.monthly
/etc/cron.quarter-daily
/etc/cron.quarter-hourly
/etc/cron.weekly

Hope this helps

Kaith Sutai-Rustaz
02-12-2001, 12:56 PM
Thanks. I apreciate the info on Cron how-tos too, as I honestly have no clue on em, and would hate to start world war III cuz of a typo. :beer:

Looks like that will do the trick.

Again, thanks!

allan
02-12-2001, 01:00 PM
Great...glad it helped. And no worries, unless the RaQ starts asking "Would you like to play a game?" you are okay.

Kaith Sutai-Rustaz
02-16-2001, 03:30 PM
Got the script installed. Had a few hiccups as it couldn't find the config file (which docs refer to as being part of the actual file), but a little cut n paste magic and I got it up and running great.

Also got a little gzip cron running that shrinks the bugger to a managable size. Question now is, is there an easy way to set cron up to run on the last day of the month?

Again Thanks!

allan
02-16-2001, 04:02 PM
Actually, the easiest way is to set it to run on the first day of the month :).

Kaith Sutai-Rustaz
02-16-2001, 04:12 PM
Problem is the server resets the logs then. So if I ran it then, I'd always be backing up clean logs, rather than full ones. right now, i've got it doing it daily, to a new file, with gzip squashing the file to a more manageable size, but I end up with alot of redundant data.

I'm gonna go do a lil digging in the mean time, but I'm open to suggestions.

thanks again.

allan
02-16-2001, 09:04 PM
The quick, kludgy way to do this would be to set a cron job to do what you want you and schedule it to run the 28th, 30th and 31st.

A more elegant method would be to schedule the cron job to run every day. The cron job would run a perl script that checks the date, and if the date matches a preset date it performs an action, otherwise it doesn't do anything.

Let me know if that helps.