954,576 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Complicated chron job

Hi I would like a crhon job to do the following:

1) copy a zip file, eg: www.somesite.com/file.zip to www.mysite.com/file.zip
2) unzip such file
3) move the unziped files to another directory, after reading one of those files.

Please, I have no idea on how to do this... (my thing is C#.net)

Thanks for your sugestions :)

RicardoE
Junior Poster in Training
73 posts since Jan 2010
Reputation Points: 21
Solved Threads: 7
 

Visit http://www.thesitewizard.com/general/set-cron-job.shtml
it will provide you with details and instructions
I hope this was helpfull

saadsaidi
Newbie Poster
17 posts since Mar 2008
Reputation Points: 9
Solved Threads: 3
 

Have you searched Google or the php manual? This is a php forum to help with your code. Show your code so far.

diafol
Rhod Gilbert Fan (ardav)
Moderator
7,792 posts since Oct 2006
Reputation Points: 1,170
Solved Threads: 1,080
 

ah don't worry guys, I figured it out, a few hours later the past week xD

in a small brief, this is what I did.

1) lots of JSON parsing and data extraction

Then I downloaded the zip file to my server like:

set_time_limit(0);
    copy($url, 'file.zip');


after that, unziped the file

$zip = new ZipArchive;
    if ($zip->open('game.zip') === TRUE) {
        $zip->extractTo('./');
        $zip->close();
        echo 'unzip ok <br/>';
    } else {
        echo 'unzip failed';
    }

//here more JSON parsing, and fun stuff

and finally copied the original to a new directory, and deleted the one in my "chron_job_folder", using the 2 following methods:

//copy the directory recursively
function full_copy($source, $target) {
    if (is_dir($source)) {
        @mkdir($target);
        $d = dir($source);
        while (FALSE !== ( $entry = $d->read() )) {
            if ($entry == '.' || $entry == '..') {
                continue;
            }
            $Entry = $source . '/' . $entry;
            if (is_dir($Entry)) {
                full_copy($Entry, $target . '/' . $entry);
                continue;
            }
            copy($Entry, $target . '/' . $entry);
        }

        $d->close();
    } else {
        copy($source, $target);
    }
}

//reomove the directory recursively
function rrmdir($dir) {
   if (is_dir($dir)) {
     $objects = scandir($dir);
     foreach ($objects as $object) {
       if ($object != "." && $object != "..") {
         if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object);
       }
     }
     reset($objects);
     rmdir($dir);
   }
 }


and, the responses to my post from ppl trying to help = 0 (again)

I guess this days, everybody is so busy. but I leave the complete solution to 3 common troubles here :) because I like to share knowledge, As my university slogan said: "Go and teach everybody".

I hope someone finds this post usefull :)

RicardoE
Junior Poster in Training
73 posts since Jan 2010
Reputation Points: 21
Solved Threads: 7
 

oh and of course... to set the cron job, simply go to your cPanel and add new cron job
there are a few nice features to make this easy, but basically you type in:

path_to_php -q full_path_to_your_php_script

and voila, you got it :)

RicardoE
Junior Poster in Training
73 posts since Jan 2010
Reputation Points: 21
Solved Threads: 7
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: