Question

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

Was it helpful?

Solution

You're not using the correct command for calling Kohana.

Make sure you're using the full path to index.php so you can eliminate any path errors. Here are the switches available for use in Kohana:

  • --uri: Self explanatory
  • --method: HTTP Request method (POST, GET, etc ...) (Overrides Kohana::$method)
  • --get: Formatted GET data
  • --post: Formatted POST data

You should be using something like this:

php /path/to/kohana/directory/index.php --uri=properties/update/

I can't remember if you need double quotes around the value, don't forget to try that if it doesn't work.

OTHER TIPS

you probably aren't running Cron with root permissions on that file.

put mailto="youremail@yourdomain.tld" at the start of the cron file to have it email you errors.

If you don't have root access to the cron file (I.E. SSH) I don't know if you can do this in cPanel.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top