0

I am running a cron job using the cron_dispatcher.php file. But I'm getting the following error message:

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

My Code at Line 87 is

define('CRON_DISPATCHER', true);
if ($argc == 2) {
    $Dispatcher = new Dispatcher();
    $Dispatcher -> dispatch($argv[1]);

My cron command is /web/cgi-bin/php5 /my/path/to/html/app/webroot/cron_dispatcher.php /users/test/

Thank you.

EDIT Solved:. Solution is run cron command in CLI mode /usr/local/php5/bin/php (Godaddy Server Specific).

It will show error but ultimatly run the controller's action.

Thanks for every one especially "VSTM".

dogmatic69
  • 7,574
  • 4
  • 31
  • 49
Confused
  • 1,602
  • 15
  • 25
  • 2
    Can you check if [`register_argc_argv`](http://www.php.net/manual/en/ini.core.php#ini.register-argc-argv) is set to "1" in your php.ini? If it is, are you sure you're calling the script with the PHP-CLI and not with PHP-CGI? (adding the cron-line to your question might help us) – vstm Nov 30 '12 at 05:34
  • I have included cron line now. – Confused Nov 30 '12 at 05:47
  • Thanks vstm I got a way to solve it. – Confused Nov 30 '12 at 06:04
  • possible duplicate of [Cron Dispatcher CakePHP 2.0](http://stackoverflow.com/a/23636079/761202) (although it's a different version of CakePHP - the answer is the same). – AD7six May 13 '14 at 16:00

1 Answers1

1

The variables $argc and $argv only exist if the relevant php.ini directive is enabled.

You should instead use $_SERVER['argc'] and $_SERVER['argv'].

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592