Portable Cron: Difference between revisions
Jump to navigation
Jump to search
m
Reverted edits by Upazixorys (Talk); changed back to last version by Ric
Upazixorys (talk | contribs) No edit summary |
m (Reverted edits by Upazixorys (Talk); changed back to last version by Ric) |
||
Line 1: | Line 1: | ||
<span id="top"></span> | |||
<div style="padding:0;margin:0; border-bottom:3px inset #000000"> | |||
{| | {| | ||
| [[Image:uc_small_logo.gif | MPG UniCenter]] || | | [[Image:uc_small_logo.gif | MPG UniCenter]] || | ||
Portable Cron design running on Uniform Server 3.5-Apollo | Portable Cron design running on Uniform Server 3.5-Apollo | ||
|} | |} | ||
</div> | |||
{| cellpadding= | {| cellpadding="2" | ||
| | | | ||
__TOC__ | __TOC__ | ||
Line 21: | Line 20: | ||
When logged in as administrator you can run the cron job manually using a link provided. Alternatively run the script from a browser by typing the following: | When logged in as administrator you can run the cron job manually using a link provided. Alternatively run the script from a browser by typing the following: | ||
''' | '''<nowiki>http://localhost/cron.php</nowiki>''' or if install in a separate folder named “drupal” '''<nowiki>http://localhost/drupal/cron.php</nowiki>''' | ||
On a local server all that is required is to run '''cron.php''' from a batch file using PHP in CLI mode (check out this [[New Users: Quick PHP CLI | page for CLI mode]]) | On a local server all that is required is to run '''cron.php''' from a batch file using PHP in CLI mode (check out this [[New Users: Quick PHP CLI | page for CLI mode]]) | ||
Line 29: | Line 28: | ||
== Batch file - intro == | == Batch file - intro == | ||
Create a batch file named '''run_cron.bat''' add the following two lines and save it in folder “'''Uniform Server'''”: | Create a batch file named '''run_cron.bat''' add the following two lines and save it in folder “'''Uniform Server'''”: | ||
<pre> | |||
udrive\usr\local\php\php.exe -n udrive\www\cron.php | udrive\usr\local\php\php.exe -n udrive\www\cron.php | ||
pause | pause | ||
</pre> | |||
PHP is run with switch '''–n''' this prevents PHP loading a configuration file (''php.ini''). Second parameter is the path and file name of the file to be run. | PHP is run with switch '''–n''' this prevents PHP loading a configuration file (''php.ini''). Second parameter is the path and file name of the file to be run. | ||
Line 47: | Line 46: | ||
You will see a list of warnings and a fatal error message similar to this: | You will see a list of warnings and a fatal error message similar to this: | ||
<pre> | |||
J:\drupal_server\Uniform Server | J:\drupal_server\Uniform Server>udrive\usr\local\php\php.exe -n udrive\www\cron.php | ||
Warning: include_once(./includes/bootstrap.inc): failed to open stream: No such file or directory in J:\drupal_server\Un | Warning: include_once(./includes/bootstrap.inc): failed to open stream: No such file or directory in J:\drupal_server\Un | ||
iform Server\udrive\www\cron.php on line 9 | iform Server\udrive\www\cron.php on line 9 | ||
Line 56: | Line 55: | ||
e 10 | e 10 | ||
J:\drupal_server\Uniform Server | J:\drupal_server\Uniform Server>pause | ||
Press any key to continue . . . | Press any key to continue . . . | ||
</pre> | |||
I have included the above to highlight paths are local and not server relative as expected by Drupal. The solution is to run '''cron.php''' on your live server as explained below. | I have included the above to highlight paths are local and not server relative as expected by Drupal. The solution is to run '''cron.php''' on your live server as explained below. | ||
Line 64: | Line 63: | ||
== Additional script and new batch file == | == Additional script and new batch file == | ||
Create a new PHP script named '''run_cron.php''' containing the following code and save it to folder containing '''cron.php'''. | Create a new PHP script named '''run_cron.php''' containing the following code and save it to folder containing '''cron.php'''. | ||
<pre> | |||
<? $dummy = file("http://localhost/cron.php"); ?> | |||
</pre> | |||
This script executes the '''file''' function reading the content of cron.php into a dummy array (the variable $dummy is never used). What’s important is the path to the file, its what would be typed into a browser meaning that page is run on the server with correct paths to other files it calls. | This script executes the '''file''' function reading the content of cron.php into a dummy array (the variable $dummy is never used). What’s important is the path to the file, its what would be typed into a browser meaning that page is run on the server with correct paths to other files it calls. | ||
Change the batch file to call this new script as follows: | Change the batch file to call this new script as follows: | ||
<pre> | |||
udrive\usr\local\php\php.exe -n udrive\www\run_cron.php | udrive\usr\local\php\php.exe -n udrive\www\run_cron.php | ||
pause | pause | ||
</pre> | |||
Run the new batch file this time there will be no errors. | Run the new batch file this time there will be no errors. | ||
Line 93: | Line 92: | ||
== Batch file with delay loop == | == Batch file with delay loop == | ||
Modify run_cron.bat as follows: | Modify run_cron.bat as follows: | ||
<pre> | |||
:next | :next | ||
ping 1.1.1.1 -n 1 -w 60000 | ping 1.1.1.1 -n 1 -w 60000 > nul | ||
udrive\usr\local\php\php.exe -n udrive\www\run_cron.php | udrive\usr\local\php\php.exe -n udrive\www\run_cron.php | ||
goto :next | goto :next | ||
</pre> | |||
The ping command introduces a delay of 60 seconds (60000ms). After this delay cron-job is run and loops back to “next” repeating the whole process. | The ping command introduces a delay of 60 seconds (60000ms). After this delay cron-job is run and loops back to “next” repeating the whole process. | ||
Line 108: | Line 107: | ||
Create a new batch file in folder “Uniform Server” named run_cron_hidden.bat and add the following lines: | Create a new batch file in folder “Uniform Server” named run_cron_hidden.bat and add the following lines: | ||
<pre> | |||
start udrive\home\admin\program\uniserv.exe run_cron.bat | start udrive\home\admin\program\uniserv.exe run_cron.bat | ||
pause | pause | ||
</pre> | |||
Run this new batch file, when requested press any key this closes the command window however run_cron command window remains running and hidden. | Run this new batch file, when requested press any key this closes the command window however run_cron command window remains running and hidden. | ||
Line 122: | Line 121: | ||
J:\drupal_server\Uniform Server\udrive\www\run_cron.php | J:\drupal_server\Uniform Server\udrive\www\run_cron.php | ||
<pre> | |||
<? $dummy = file("http://localhost/cron.php"); ?> | |||
</pre> | |||
J:\drupal_server\Uniform Server\run_cron_hidden.bat | J:\drupal_server\Uniform Server\run_cron_hidden.bat | ||
<pre> | |||
start udrive\home\admin\program\uniserv.exe run_cron.bat | start udrive\home\admin\program\uniserv.exe run_cron.bat | ||
</pre> | |||
J:\drupal_server\Uniform Server\run_cron.bat | J:\drupal_server\Uniform Server\run_cron.bat | ||
<pre> | |||
:next | :next | ||
unidelay.exe 60 | unidelay.exe 60 | ||
Line 136: | Line 135: | ||
goto :next | goto :next | ||
exit | exit | ||
</pre> | |||
Note: '''unidelay.exe 60''' runs the cron-job every 60 seconds increase this as required. | Note: '''unidelay.exe 60''' runs the cron-job every 60 seconds increase this as required. |