Cron Design: Introduction: Difference between revisions
(New page: {{Nav Cron Design}} Portable Cron was integrated into Uniform Server 5-Nano although useful suffered from a number of limitations. A new design has addressed these issues and offers more f...) |
(Proofreading and grammatical changes) |
||
Line 1: | Line 1: | ||
{{Nav Cron Design}} | {{Nav Cron Design}} | ||
Portable Cron was integrated into Uniform Server 5-Nano | Portable Cron was integrated into Uniform Server 5-Nano. Although useful, it suffered from a number of limitations. A new design has addressed these issues and offers more flexibility. | ||
That said you may find it does not meet your particular requirements solution is to design new scripts or modify the existing ones. | That said, you may find it does not meet your particular requirements. The best solution is to design new scripts or modify the existing ones. | ||
The following provides a detailed description of the current implementation, which you can use as a basis for new designs or tweak the | The following provides a detailed description of the current implementation, which you can use as a basis for new designs or tweak the existing scripts. | ||
== Background == | == Background == | ||
Before looking at configuration | Before looking at configuration, this is quick overview what portable Cron is and what it is not. | ||
=== Cron === | === Cron === | ||
Cron originated from a Unix environment | Cron originated from a Unix environment. It is a job scheduler that allows scripts to be run automatically at a certain time or date. | ||
Cron (chronograph) has become a more general term referring to a periodic tick. | Cron (chronograph) has become a more general term referring to a periodic tick. | ||
=== Portable Cron === | === Portable Cron === | ||
Why portable Cron? | Why portable Cron? For a permanent installation of UniServer running as a service, you can set up Windows to schedule a task similar to Unix Cron. Check out [http://support.microsoft.com/kb/308569 How To Schedule Tasks in Windows XP] for details | ||
This is not practical when running UniServer from a USB memory stick which implies portability you need to reconfigure each new machine. UniServer 5 | This is not practical when running UniServer from a USB memory stick, which implies portability. It means you need to reconfigure each new machine. UniServer 5-Nano resolves this with a small script scheduler referred to as portable Cron. | ||
It’s fully integrated into UniServers’s control architecture allowing it to be run from either batch files or UniTray. | It’s fully integrated into UniServers’s control architecture, allowing it to be run from either batch files or UniTray. | ||
== Configuration == | == Configuration == | ||
To understand the design it’s worth first looking at configuration. Knowing how to configure Cron also serves as a specification. | To understand the design, it’s worth first looking at configuration. Knowing how to configure Cron also serves as a specification. | ||
To run each individual script a number of parameters are set in a configuration file '''cron.ini''' This file has a standard format making it very easy to | To run each individual script, a number of parameters are set in a configuration file: '''cron.ini'''. This file has a standard format making it very easy to set up and use. | ||
Each script to be run is defined in a self-contained block. Each block starts with a unique header | Each script to be run is defined in a self-contained block. Each block starts with a unique header. Here's an example: | ||
<pre> | <pre> | ||
[moodle] | [moodle] | ||
Line 36: | Line 34: | ||
ref = | ref = | ||
</pre> | </pre> | ||
=== Explanation === | === Explanation === | ||
{| | {| | ||
Line 50: | Line 48: | ||
|'''ref''' ||- A tracker set by Cron script effectively time to next run. Deleting this value allows a new start time to be set (covered later) | |'''ref''' ||- A tracker set by Cron script effectively time to next run. Deleting this value allows a new start time to be set (covered later) | ||
|} | |} | ||
=== Detail === | === Detail === | ||
{| | {| | ||
Line 95: | Line 93: | ||
'''''Note 1'':''' Cron automatically updates ref with the initial start time set and<br /> | '''''Note 1'':''' Cron automatically updates ref with the initial start time set and<br /> | ||
period. Every time a script is run the value is updated with a new Cron reference<br /> | period. Every time a script is run, the value is updated with a new Cron reference.<br /> | ||
This defines when the next run is to start. | |||
'''''Note 2'':''' To specify a new start time first set a new value for start and<br /> | '''''Note 2'':''' To specify a new start time first set a new value for start and<br /> | ||
delete the ref number (if there is one), save the file. The script will run at the<br /> | delete the ref number (if there is one), then save the file. The script will run at the<br /> | ||
date and time set and thereafter at a period you defined | date and time set and thereafter at a period you defined. | ||
|} | |} | ||
== General notes == | == General notes == | ||
Configuration file location: UniServer\unicon\main\'''cron.ini''' | Configuration file location: UniServer\unicon\main\'''cron.ini''' | ||
Line 122: | Line 120: | ||
* <nowiki>http:</nowiki>//localhost:81/drupal/cron.php | * <nowiki>http:</nowiki>//localhost:81/drupal/cron.php | ||
== How to run portable Cron == | == How to run portable Cron == | ||
Line 138: | Line 135: | ||
* To stop Cron: Double click on Stop_Cron.bat | * To stop Cron: Double click on Stop_Cron.bat | ||
=== Automatic === | === Automatic === | ||
Line 158: | Line 154: | ||
"%PHP%\php.exe"; Parameters: " -n %ServerConMain%\stop_servers.php 7";ShowCmd: hidden; Glyph: 11 | "%PHP%\php.exe"; Parameters: " -n %ServerConMain%\stop_servers.php 7";ShowCmd: hidden; Glyph: 11 | ||
</pre> | </pre> | ||
== Logging == | == Logging == |
Latest revision as of 02:05, 13 February 2010
Cron Design: Introduction | Running Cron | Cron Script Part 1 | Cron Script Part 2 | Cron Script Part 3
|
Uniform Server Portable Cron Design |
Portable Cron was integrated into Uniform Server 5-Nano. Although useful, it suffered from a number of limitations. A new design has addressed these issues and offers more flexibility.
That said, you may find it does not meet your particular requirements. The best solution is to design new scripts or modify the existing ones.
The following provides a detailed description of the current implementation, which you can use as a basis for new designs or tweak the existing scripts.
Background
Before looking at configuration, this is quick overview what portable Cron is and what it is not.
Cron
Cron originated from a Unix environment. It is a job scheduler that allows scripts to be run automatically at a certain time or date.
Cron (chronograph) has become a more general term referring to a periodic tick.
Portable Cron
Why portable Cron? For a permanent installation of UniServer running as a service, you can set up Windows to schedule a task similar to Unix Cron. Check out How To Schedule Tasks in Windows XP for details
This is not practical when running UniServer from a USB memory stick, which implies portability. It means you need to reconfigure each new machine. UniServer 5-Nano resolves this with a small script scheduler referred to as portable Cron.
It’s fully integrated into UniServers’s control architecture, allowing it to be run from either batch files or UniTray.
Configuration
To understand the design, it’s worth first looking at configuration. Knowing how to configure Cron also serves as a specification.
To run each individual script, a number of parameters are set in a configuration file: cron.ini. This file has a standard format making it very easy to set up and use.
Each script to be run is defined in a self-contained block. Each block starts with a unique header. Here's an example:
[moodle] start = 2009-09-21 2:56:00 period = hourly path = http://localhost/moodle/admin/cron.php ref =
Explanation
[moodle] | - Header a unique name enclosed in square brackets. |
start | - Time you initially want the script to start (seconds are ignored) |
period | - How often the script is to be run after the initial start |
path | - Full path and name of the script to be run |
ref | - A tracker set by Cron script effectively time to next run. Deleting this value allows a new start time to be set (covered later) |
Detail
[moodle] |
|
Header uniquely names this block note no spaces allowed in name. |
start |
= |
Initial start time when script is to be run it has the following format: |
period |
= |
How often to run script from the above reference start time |
path |
= |
Two types of scripts are runnable with paths as follows:
|
ref |
= |
A time stamp updated by the Cron script. Initial value is set by a user value blank. Note 1: Cron automatically updates ref with the initial start time set and Note 2: To specify a new start time first set a new value for start and |
General notes
Configuration file location: UniServer\unicon\main\cron.ini
Configuration file contains pre-configured CLI blocks dtdns and db_backup. Uncomment to enable either block (remove semicolons).
Paths
The configuration file also contains pre-configured Web blocks drupal and moodle. Again uncomment to enable a block.
Note 1: If these were installed to a different folder change the path accordingly.
Note 2: If you have moved the servers remember to add a port number to the URL.
For example moving the servers once, Apache port becomes 81 hence these two paths:
- http://localhost/moodle/admin/cron.php
- http://localhost/drupal/cron.php
Become:
- http://localhost:81/moodle/admin/cron.php
- http://localhost:81/drupal/cron.php
How to run portable Cron
Manually
Portable Cron is run from one of two locations.
UniTray:
- Left or Right mouse click tray icon
- To run Cron: Advanced > Start Portable Cron
- To stop Cron: Advanced > Stop Portable Cron
Alternative Control:
- Navigate to folder UniServer\alternative_control
- To run Cron: Double click on Start_Cron.bat
- To stop Cron: Double click on Stop_Cron.bat
Automatic
Cron can be configured to run automatically when the servers are started.
Edit file UniServer\unicon\tray_menu\UniTray1.ini
These four lines (lines three and four split on purpose to prevent breaking the Wiki) control Server Start and Stop.
Change binary code from 7 to 23 for lines three and four.
;=== LEFT MENU ============ [Menu.Left] Type: item; Caption: "Start UniServer (Apache MySQL)"; Action: shellexecute; FileName: "%PHP%\php.exe"; Parameters: " -n %ServerConMain%\start_servers.php 7";ShowCmd: hidden; Glyph: 9 Type: item; Caption: "Stop UniServer (Apache MySQL)"; Action: shellexecute; FileName: "%PHP%\php.exe"; Parameters: " -n %ServerConMain%\stop_servers.php 7";ShowCmd: hidden; Glyph: 11
Logging
Cron logs the fooling information:
- Time Cron was started
- Start time and path of a script that is run
- Time Cron was stopped. Note if missing from log means servers were not shut down before tuning PC off
Cron logging is enabled by default this can be disabled by editing the following file:
UniServer\unicon\main\run_cron.php
- Change line: $logging = true;
- To: $logging = false;
Note: Name and location of log file is : UniServer\unicon\main\cron_log.txt
Summary
Above is essentially a user interface and to a certain extent the design specification.
Remaining pages looks at design; first we take a more detailed look at running Cron.