News:

Wondering if this will always be free?  See why free is better.

Main Menu

Running a script through cron

Started by Alex4108, January 16, 2012, 06:39:58 PM

Previous topic - Next topic

Alex4108

Hey SMF!

I want to run my script through cron.  Its an addon to an awards plugin, that checks users registration dates and issues time based awards.  My script is including SSI.php, however I get this error when the script actually runs in cron:

PHP Notice:  Undefined index:  REMOTE_ADDR in /home/rgclan/public_html/bb/Sources/ManageSearchEngines.php on line 468

Halp?

Arantor

Well, it's a bit hackish but just before your custom script loads SSI.php, you can add:
$_SERVER['REMOTE_ADDR'] = '';
Holder of controversial views, all of which my own.


Alex4108

Quote from: arrowtotheknee on January 16, 2012, 06:53:18 PM
Well, it's a bit hackish but just before your custom script loads SSI.php, you can add:
$_SERVER['REMOTE_ADDR'] = '';

I don't think you can modify $_SERVER variables.

Oh well, I followed this: http://www.simplemachines.org/community/index.php?topic=329894.0 and got it working

~Solved

Arantor

Yes, you can modify $_SERVER variables. Once they enter PHP, they're just regular variables in a global scope.

Still, there is an advantage to using cron vs scheduled tasks - cron will always run, while scheduled tasks can only run if the forum is actively loaded during that time (since browsing the forum will trigger the task check/run), mind you if the search engines are viewing your site it usually isn't a problem.
Holder of controversial views, all of which my own.


Advertisement: