UnitedForums - UK Web Hosting Forum UnitedHosting Community Hosting Forums
Network and Server StatusCustomer SupportUK Web Hosting
UnitedHostingUnitedHosting Sitemap UK Hosting ForumUK Web HostingWeb Hosting ForumsUK Reseller HostingWeb Host CommunityUK Managed Dedicated ServersHosting Help and SupportUK Domain Name Registration

Go Back   UnitedForums.co.uk > UnitedHosting Community > Website Development & Scripting

Reply
 
Thread Tools Rate Thread Display Modes
Old 29th July 2003, 11:54 AM   #1 (permalink)
sticky
GamingGeek
 
sticky's Avatar
 
Join Date: Jan 2003
Location: Southsea, UK
Posts: 265
Simple Script for CronJob

I need to move the daily access log on my hosting account to a new folder in order to keep them all past 14 days. I will be setting this up as a simple CronJob that will execute at 11.59pm each day.
Code:
59 23 * * * /var/www/html/dailylog/backuplog.php
I have tested the rename section and it works ok, but I don't have access to the log directory from my browser to check the copy file code, I'm getting a permission denied error, presumably this won't happen when it's up and running on the server.
Code:
<?

$logname = "access_log.2.gz"; // daily log file
$Fromdir = "/var/log/httpd/"; // copy from
$ToDir = "/var/www/html/stickylog/"; // copy to
$date = date("d-m-y"); // set date format

copy($Fromdir,$ToDir);

rename($logname, $date . ".gz");

?>
My knowledge of PHP (and CronJobs etc.) is not that great so I just wanted a second pair of eyes to go over it before I things in motion

Cheers!
sticky is offline   Reply With Quote
Old 29th July 2003, 11:56 AM   #2 (permalink)
UH-Matt
Administrator
 
UH-Matt's Avatar
 
Join Date: Oct 2002
Location: London, UK
Posts: 8,135
To test it try the following paths:


Code:
$Fromdir = "/home/virtual/domain.com/var/log/httpd/"; // copy from
$ToDir = ""/home/virtual/domain.com/var/www/html/stickylog/"; // copy to
replace domain.com with your domain.
__________________
.
Matt
UnitedHosting Staff

For official support please use our helpdesk at UnitedSupport.co.uk

UnitedHosting proudly hosting more than 20,000 sites since 1998.
UH-Matt is offline   Reply With Quote
Old 29th July 2003, 02:36 PM   #3 (permalink)
YoYo
Senior Member
 
Join Date: Feb 2003
Location: USA
Posts: 134
Where does this go in your code?

I thought Matt or Simon had to setup cron jobs. I'm guessing they did set this up for you?

59 23 * * * /var/www/html/dailylog/backuplog.php
__________________
I'm an American, 95.8% of the world hates me.

Last edited by YoYo : 29th July 2003 at 02:41 PM.
YoYo is offline   Reply With Quote
Old 29th July 2003, 02:49 PM   #4 (permalink)
sticky
GamingGeek
 
sticky's Avatar
 
Join Date: Jan 2003
Location: Southsea, UK
Posts: 265
Thanks for that Matt, although it was my coding fault, I needed to add the actual filenames on the end as below.
Quote:
<?

$logname = "access_log.2.gz"; // daily log file
$Fromdir = "/home/virtual/mydomain.org/var/log/httpd/access_log.2.gz"; // copy from
$ToDir = "/home/virtual/mydomain.org/var/www/html/dailylog/access_log.2.gz"; // copy to
$date = date("d-m-y"); // set date format

copy($Fromdir,$ToDir);

rename($logname, $date . ".gz");

echo "Done"

?>
Quote:
I thought Matt or Simon had to setup cron jobs. I'm guessing they did set this up for you?
They do, I'm just about to submit a ticket

It's not setup yet, just wanted to get the script working which it does perfectly now

Last edited by sticky : 29th July 2003 at 02:56 PM.
sticky is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 05:08 PM.

UK Web Hosting  |  UK Reseller Hosting  |  UK Dedicated Servers UnitedHosting  |  UnitedSupport  |  UnitedForums  |  SEO by vBSEO 3.0.0
Copyright © 1998-2008 United Communications Limited. All Rights Reserved. Registered in England and Wales 3651923 - VAT Reg No. 737662309