PDA

View Full Version : Cron Job to Copy Log Files


ukpages
11-20-2006, 04:20 AM
I want to setup a Cron job to copy my log files, as log files are only kept for 7 days. Can anyone help me with a unix command that might work please? I can see where to enter the Cron job in the control panel, but what command might I use?

I want to copy '/hsphere/local/home/ukpages/logs/withernsea-carnival.co.uk/*.gz' to '/hsphere/local/home/ukpages/admin.withernsea-carnival.co.uk/rawlogs/'

But if I do that each week, the file names will be the same and will overwrite the old logs. Is there a way to change the filename or add them all to a single gz file perhaps using the date at a filename?

Also, which time and day would be best to do the copy, to make sure the entire weeks log files are there waiting to be copied?

Many thanks
Colin Davis
webmaster@ukpages.org

Senad
11-23-2006, 05:38 PM
The only way to do this that I am aware of is to create a script that will rotate the log based on x days or x size and rename it. Then you would run that script via ssh.