First, let me say that I know nothing about Cron Jobs or PHP files, so please keep my newbie status in mind if you are kind enough to reply - (use small words and speak slowly!)
I am the webmaster for our organization's site, and I am trying to do something which should be simple, yet time consuming: Take the main web page on our site and automatically update it during the Thanksgiving and Christmas Holidays. I have already created the specific web pages that I need, and uploaded them to the GoDaddy server, but I really don't have the time to go in and manually rename the pages as the days approach; I'm told that a Cron Job would be just the thing to use to automatically save the existing page and rename the new page.
Here is specifically what I want to do: 1) The file Index.htm, located in the root directory, gets either saved or renamed so that I can go back to it after the Holidays are over. 2) The file now named /Holiday Pages/happy_thanksgiving.htm gets moved to the root directory on November 25th and renamed index.htm Same thing with the file named merry_christmas.htm on December 24th. 3) GoDaddy has a Cron Job control panel which allows me to run a specific script on a certain day at a certain time, so I don't think the date codes would need to be embedded into the script itself - but I've not a clue what to put in this script - from talking to the folks at GoDaddy, they suggest a PHP script. 4) Within this PHP script, exactly what commands would I need to write (specific examples please - a sample script would be awesome and MOST appreciated! 5) What would the extension on this script need to be? .TXT or .PHP ??
Thanks in advance! Again, please remember that I'm in over my head here - and pardon my ignorance!
-------------------------------------------------------UPDATE 111/15/14 -------------------------------------------------------- Here's what I have tried so far, using some of your suggestions - the numbers 1) 2) etc are trial script numbers which were then called by the GoDaddy's Cron Job Manager.
1) ----------------------------------------------
<?php
$target = "/holiday_pages/happy_thanksgiving.html";
$newName = "/holiday_pages/index.htm";
$renameResult = rename($target, $newName);
// Evaluate the value returned from the function if needed
if ($renameResult == true) {
echo $target . " is now named " . $newName;
} else {
echo "Could not rename that file";
}
?>
2) ------------------------------------------------
rename('/holiday_pages/happy_thanksgiving.html', '/holiday_pages/index.htm');
3) ------------------------------------------------
rename("/holiday_pages/happy_thanksgiving.html", "/home/user/password/holiday_pages/index.htm");
?>
4) ------------------------------------------------
<?php
$date = new DateTime();
$date -> format('Y.m.d');
if ($date == '2014.11.15') {
copy('./HTML/holiday_pages/index.htm','index.htm.bak');
copy('./HTML/holiday_pages/happy_thanksgiving.html','index.htm'); // you need to make sure if this (../Holiday Pages/) is the right path to your file!
}
else if ($date == '2014.11.26') {
copy('index.htm.bak','index.htm');
}
5) --------------------------------------------------
<?php
$date = new DateTime();
$date -> format('Y.m.d');
if ($date == '2014.11.15') {
copy('../HTML/holiday_pages/index.htm','index.htm.bak');
copy('../HTML/holiday_pages/happy_thanksgiving.html','index.htm'); // you need to make sure if this (../Holiday Pages/) is the right path to your file!
}
else if ($date == '2014.11.26') {
copy('index.htm.bak','index.htm');
}
6) --------------------------------------------------
<?php
$date = new DateTime();
$date -> format('Y.m.d');
if ($date == '2014.11.15') {
copy('/HTML/holiday_pages/index.htm','index.htm.bak');
copy('/HTML/holiday_pages/happy_thanksgiving.html','index.htm'); // you need to make sure if this (../Holiday Pages/) is the right path to your file!
}
else if ($date == '2014.11.26') {
copy('index.htm.bak','index.htm');
}
7) ---------------------------------------------------
<?php
$date = new DateTime();
$date -> format('Y.m.d');
if ($date == '2014.11.15') {
copy('./holiday_pages/index.htm','index.htm.bak');
copy('./holiday_pages/happy_thanksgiving.html','index.htm'); // you need to make sure if this (../Holiday Pages/) is the right path to your file!
}
else if ($date == '2014.11.26') {
copy('index.htm.bak','index.htm');