CRON - No URI present madness |
[eluser]kaosweaver[/eluser]
Alright, I'm out of ideas on how to solve this issue. I've searched for the solution and tried a variety of them to no avail. Here is the situation, I've setup a separate index.php file for a cron job to call and execute the cron jobs, I use: Code: $_SERVER['PATH_INFO'] = '/cron/tasks'; The config has the uri_protocol set to auto Code: $config['uri_protocol'] = 'AUTO'; If I type in the URL for the cron's index.php (http://mysite.com/cronfolder/) the functions perform exactly as desired. (paths set to the right folders, emails are sent, data is accurate, etc) I've tried to set the uri_protocol to all of the options, still has the same result, nothing. (or the site breaks, still doesn't work) The cron is setup to call the index file via CPanel and I know this is working (I put an email to me in the index file to check to make sure it was being called). The LOG reports: Code: DEBUG - 2012-02-02 09:31:02 --> Config Class Initialized Specifically, the line: Code: DEBUG - 2012-02-02 09:31:02 --> No URI present. Default controller set. Tells me the URI isn't being set right, but I'm perplexed because calling the file directly in a browser works (it doesn't have any output on the screen, but the effects happen), but calling it via a CRON set in CPanel loses the URI - calls the file right, just loses the URI, I don't know how to fix as it is right in the index.php file (code block 1). Any suggestions?
[eluser]CroNiX[/eluser]
Its because you are executing the cron job from the local host, not from a URL, which relies on the appropriate $_SERVER variables being set which doesn't happen with cron. Check this out: http://ellislab.com/forums/viewthread/88635/ It lets you set these variables when being called from a cron job so everything works as though the request came from the net instead of a local cron job. I've used this a lot for pre CI2. Haven't tried with CI 2, so... One thing you might do is detect if php is being executed via cron, and if so, set some server vars CI needs like Code: if (php_sapi_name() == 'cli') |
Welcome Guest, Not a member yet? Register Sign In |