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!
