Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7026263
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:05:39+00:00 2026-05-28T00:05:39+00:00

I am using CakePHP 2.0 and have been trying to setup a cronjob to

  • 0

I am using CakePHP 2.0 and have been trying to setup a cronjob to execute a method in a controller. I’ve been going nuts, looking over various tutorials and random sites to see if I could find a solution.

The error I am receiving is this:

Undefined variable: argc [APP/webroot/cron_dispatcher.php, line 83

Here is the bottom of the cron_dispatcher.php file in my app/webroot/ directory.

if (!include(CORE_PATH . 'cake' . DS . 'bootstrap.php')) {
        trigger_error("CakePHP core could not be found.  Check the value of CAKE_CORE_INCLUDE_PATH in APP/webroot/index.php.  It should point to the directory containing your " . DS . "cake core directory and your " . DS . "vendors root directory.", E_USER_ERROR);
    }
    if (isset($_GET['url']) && $_GET['url'] === 'favicon.ico') {
    return;
    } else {
      define('CRON_DISPATCHER',true);
    if($argc >= 2) {
        $Dispatcher= new Dispatcher();
        $Dispatcher->dispatch($argv[1]);
        }
    }

I cannot find where these variables ($argv and $argc) are defined. They aren’t defined anywhere in the dispatcher.php file itself. I searched Google to no avail. I’m not 100% sure how the Dispatcher works, but any help would be greatly appreciated. Thanks.

== UPDATE
GoDaddy’s shared hosting doesn’t allow you to change the settings of argc argv.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:05:40+00:00Added an answer on May 28, 2026 at 12:05 am

    In case anyone else is interested,

    In the new CakePHP 2.0.5, you will an index.php in webroot folder:

    Copy this file and name it cron_dispatcher.php, and place it into the same directory (webroot)

    You will find this code at the very bottom:

    $Dispatcher = new Dispatcher();
    $Dispatcher->dispatch(new CakeRequest(), new CakeResponse(array('charset' => Configure::read('App.encoding'))));
    

    change the bottom to

    define('CRON_DISPATCHER',true);
    $Dispatcher = new Dispatcher();
    $Dispatcher->dispatch(new CakeRequest($argv[1]), new CakeResponse(array('charset' => Configure::read('App.encoding'))));
    

    You’re doing two things here: Setting CRON_DISPATCHER to true, and passing environment variables ($argv[1]).

    In your controller, add this line before you do anything else:

    if (!defined('CRON_DISPATCHER')) { $this->redirect('/'); exit(); }
    

    This will ensure people going to yoursite.com/controller/cronaction won’t be able to run your script.

    In your htaccess file in webroot, add this:

    <Files  "cron_dispatcher.php">
        Order deny,allow
        Deny from all
    </Files>
    

    This will ensure poeple going to yoursite.com/cron_dispatcher.php won’t be able teo run it.

    Now set up the cron job using something like the command:

    php /home/yoursite/public_html/cakephp/app/webroot/cron_dispatcher.php /controller/cronjobaction
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been using Alaxos CakePHP ACLplugin for my site, which is great. However,
I have been able to use CakePHP's saveAll method to simultaneously create 'Members' and
On my local setup I have a load of different CakePHP websites. I'm using
I am using CakePHP framework with MySQL database and I have problem in saving
I'm using CakePHP but it's a question about the MVC pattern. I have in
I just started using CakePHP for a small project. I have rails experience, and
I'm developing a site using the CakePHP framework. I have a form which shows
I have used cakePHP 1.2 and know how to use behaviors in it. using
I am using JQuery and cakephp for my application. I have created a select
I have been trying to figure out how to do this and it seems

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.