How can I test a CRON job with PHP?

Posted by alex on Stack Overflow See other posts from Stack Overflow or by alex
Published on 2010-03-18T07:00:19Z Indexed on 2010/03/18 7:01 UTC
Read the original article Hit count: 317

Filed under:
|
|
|

This is the first time I've ever used a CRON.

I'm using it to parse external data that is automatically FTP'd to a subdirectory on our site.

I have created a controller and model which handles the data. I can access the URL fine in my browser and it works (however I will be restricting this soon).

My problem is, how can I test if it's working?

I've added this to my controller for a quick and dirty log

$file = 'test.txt';

        $contents = '';

        if (file_exists($file)) {

            $contents = file_get_contents($file);

        }

        $contents .= date('m-d-Y') . ' --- ' . PHP_SAPI . "\n\n";

        file_put_contents($file, $contents);

But so far only got requests logged from myself from the browser, despite having my CRON running ever minute.

03-18-2010 --- cgi-fcgi

03-18-2010 --- cgi-fcgi

I've set it up using cPanel with the command

index.php properties/update/

the 2nd portion is what I use to access the page in my browser.

So how can I test this is working properly, and have I stuffed anything up?

Note: I'm using Kohana 3.

Many thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about cron