Portable Cron: Difference between revisions

359 bytes removed ,  24 November 2010
m
Reverted edits by Upazixorys (Talk); changed back to last version by Ric
No edit summary
m (Reverted edits by Upazixorys (Talk); changed back to last version by Ric)
 
Line 1: Line 1:
=[http://ecoquvejoz.co.cc This Page Is Currently Under Construction And Will Be Available Shortly, Please Visit Reserve Copy Page]=
<span id="top"></span>
&lt;span id=&quot;top&quot;&gt;&lt;/span&gt;
<div style="padding:0;margin:0; border-bottom:3px inset #000000">
&lt;div style=&quot;padding:0;margin:0; border-bottom:3px inset #000000&quot;&gt;
{|  
{|  
| [[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  
|}
|}
&lt;/div&gt;
</div>
{| cellpadding=&quot;2&quot;
{| 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:


'''&lt;nowiki&gt;http://localhost/cron.php&lt;/nowiki&gt;''' or if install in a separate folder named “drupal” '''&lt;nowiki&gt;http://localhost/drupal/cron.php&lt;/nowiki&gt;'''
'''<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'''”:
&lt;pre&gt;
<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
&lt;/pre&gt;
</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:
&lt;pre&gt;
<pre>
J:\drupal_server\Uniform Server&gt;udrive\usr\local\php\php.exe -n udrive\www\cron.php
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&gt;pause
J:\drupal_server\Uniform Server>pause
Press any key to continue . . .
Press any key to continue . . .
&lt;/pre&gt;
</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'''.
&lt;pre&gt;
<pre>
&lt;? $dummy = file(&quot;http://localhost/cron.php&quot;); ?&gt;
<? $dummy = file("http://localhost/cron.php"); ?>
&lt;/pre&gt;
</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:
&lt;pre&gt;
<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
&lt;/pre&gt;
</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:
&lt;pre&gt;
<pre>
:next
:next
ping 1.1.1.1 -n 1 -w 60000 &gt; nul
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
&lt;/pre&gt;
</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:


&lt;pre&gt;
<pre>
start udrive\home\admin\program\uniserv.exe run_cron.bat
start udrive\home\admin\program\uniserv.exe run_cron.bat
pause
pause
&lt;/pre&gt;
</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
&lt;pre&gt;
<pre>
&lt;? $dummy = file(&quot;http://localhost/cron.php&quot;); ?&gt;
<? $dummy = file("http://localhost/cron.php"); ?>
&lt;/pre&gt;
</pre>
J:\drupal_server\Uniform Server\run_cron_hidden.bat
J:\drupal_server\Uniform Server\run_cron_hidden.bat
&lt;pre&gt;
<pre>
start udrive\home\admin\program\uniserv.exe run_cron.bat
start udrive\home\admin\program\uniserv.exe run_cron.bat
&lt;/pre&gt;
</pre>
J:\drupal_server\Uniform Server\run_cron.bat
J:\drupal_server\Uniform Server\run_cron.bat
&lt;pre&gt;
<pre>
:next
:next
unidelay.exe 60
unidelay.exe 60
Line 136: Line 135:
goto :next
goto :next
exit
exit
&lt;/pre&gt;
</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.