You are here

README.txt in Elysia Cron 7

Same filename and directory in other branches
  1. 5.2 README.txt
  2. 5 README.txt
  3. 6.2 README.txt
  4. 6 README.txt
  5. 7.2 README.txt
ELYSIA_CRON
by Eric Berdondini (gotheric)
<eric@void.it>

For installation instructions read INSTALL.TXT
For module developers API documetation read API.TXT

-----------------------------------------------------------------------------
FEATURES
-----------------------------------------------------------------------------

Elysia Cron extends Drupal standard cron, allowing a fine grain control over 
each task and several ways to add custom cron jobs to your site.

- Set the timings and frequencies of each cron task (you can run some jobs every
  day at a specified hour, other only monthly and so on...).
  For each task you can simply choose between some frequently used options 
  ("once a day", "once a month" ...), or use a powerful "linux crontab"-like 
  syntax to set the accurate timings. You can even define your frequently used 
  options to speed up site configuration.
- Parallel execution of cron task: you can group jobs in channels and execute 
  then simultaneously: so a task that takes a lot of time to execute won't block
  other tasks that need to be executed every 5 minutes...
- You can disable all tasks, an entire channel or a single task.
- Change the priority/order of task execution.
- Manual force the execution of a cron tasks.
- Detailed overview of cron status with time statistics for single tasks and 
  channels.

- Powerful API for module developers: you can define extra cron tasks for your 
  modules, each one with own default timings (site administrators can override 
  them by configuration, other modules via hook_alter). Elysia Cron 2.0 gives a 
  brand new API support (compatible with 1.0 version) with a lot of features.
- Administrators can define custom jobs (call to functions with parameters), via
  the "script" option.
- Several optimization for frequent cron calls and error handling.
- Protection from external cron calling by cron_key or allowed host list.

Elysia has no dependencies with contributed modules, and doesn't need to patch
the core: it can be used in minimal Drupal installation with only core modules.
It also can be used in a Drupal install profile.

3rd party integration:
- Ping feature, for external tracking services like host-tracker to tell whether
  cron is functioning properly on your site.
- Drush support: you can call "drush elysia-cron" to manually run extended cron.
- CTools support for exports/backup of task settings.
- Features support.

-----------------------------------------------------------------------------
USAGE EXAMPLES
-----------------------------------------------------------------------------

Elysia cron is usually used in large sites that needs performance optimization.

- Avoid drupal peak loads by distributing heavy load tasks during quiet periods 
  of the day: for example you may want to rebuild the XML Sitemap of your site 
  at 2:00AM in the morning, where usually only a few people are visiting your 
  site. You can even move some tasks to be executed only once a month (log 
  rotation, old records expiry...).

- If you have tasks that should be executed very often, but don't want to 
  execute ALL drupal cron tasks that often! For example, you may want to check 
  for emails that needs to be sent to your users every 2 minutes. Standard cron 
  is managed in a "monolithic" way, so even if you find out how to execute it 
  every 2 minutes, you will end in having all cron tasks executed so often, with
  a lot of performance problems.

- Fine tune cron cache management : drupal cron will invalidate variable cache 
  every cron run, and this is a great performance problem if you have a 
  frequently called task. Elysia cron optimize cache management, and doesn't 
  need to invalidate cache.

- Setup tasks that should be run at a precise time: for example if you want to 
  send a SimpleNews newsletter every monday at 9:00AM, you can do it.

- Parallel execution: if you have a task that takes a lot of time to execute, 
  you can setup a different channel for it so it won't block other tasks that 
  need to be executed every 5 minutes.

- Turn off (disable) a cron task/feature you don't need.

- Debug system cron problems. If your cron does not terminate correctly you can
  use extended logging, see at each cron timings and disable task to track down 
  the problem.

-----------------------------------------------------------------------------
CHANNELS
-----------------------------------------------------------------------------

Channels are groups of tasks. Each channel is a "parallel line" of execution
(= multiple channels can be executed simultaneously).
Tasks inside a channel will be executed sequentially (if they should).

WARNING: It's not recommended to create more than 2 or 3 channels.
Every channel will increase the delay between each cron check (of the same 
channel), because each cron call will cycle between all channels.
So, for example:
If you have 1 channel it will be checked once a minute.
If you have 2 channel each one will be checked every 2 minutes (almost usually, 
when the other one is running it will be checked once a minute).
It you have 10 channels there will be a check every 10 minutes... if you have
a job that should be executed every 5 minutes it won't do so!

-----------------------------------------------------------------------------
EXPORT VIA CTOOLS/FEATURES MODULE
-----------------------------------------------------------------------------

With 2.0 version of Elysia Cron you can use "Bulk Export" functionality of 
"Chaos Tools Suite" to export cron settings.
To use it simply enable all modules, go to Structure > Bulk Exporter and
select the tasks you want to export settings. You can also select all 
"elysia_cron" prefixed variables to export global options.
Than generate the module.

The generated code will set the new defaults of elysia cron settings. This way
you can simply enable it to use them, but you are free to override them in
the future using the normal settings page.
Note that if you want to delete all overrides, and return to exported settings,
you should do a "reset to defaults" from elysia cron settings page. 

You can also use "Features" module to create a Feature module will the settings
you need.
Note that if you want to delete the overridden settings it's preferable to use
the "reset to defaults" elysia cron's button.
You can use the "Revert components" Features's button, but this will reset also
all cron statistics (if you are not interested in them you can freely use that
button).

-----------------------------------------------------------------------------
DRUSH SUPPORT
-----------------------------------------------------------------------------

Elysia Cron 2.0 adds a simple support for Drush module.

You can execute the "elysia-cron" command to run cron.

-----------------------------------------------------------------------------
RULES AND SCRIPT SYNTAX
-----------------------------------------------------------------------------

1. FIELDS ORDER
---------------------------------

 +---------------- minute (0 - 59)
 |  +------------- hour (0 - 23)
 |  |  +---------- day of month (1 - 31)
 |  |  |  +------- month (1 - 12)
 |  |  |  |  +---- day of week (0 - 6) (Sunday=0)
 |  |  |  |  |
 *  *  *  *  *

Each of the patterns from the first five fields may be either * (an asterisk), 
which matches all legal values, or a list of elements separated by commas 
(see below).

For "day of the week" (field 5), 0 is considered Sunday, 6 is Saturday (7 is 
an illegal value)

A job is executed when the time/date specification fields all match the current 
time and date. There is one exception: if both "day of month" and "day of week" 
are restricted (not "*"), then either the "day of month" field (3) or the "day 
of week" field (5) must match the current day (even though the other of the two 
fields need not match the current day).

2. FIELDS OPERATOR
---------------------------------

There are several ways of specifying multiple date/time values in a field:

* The comma (',') operator specifies a list of values, for example: "1,3,4,7,8"
* The dash ('-') operator specifies a range of values, for example: "1-6", which 
  is equivalent to "1,2,3,4,5,6"
* The asterisk ('*') operator specifies all possible values for a field. For 
  example, an asterisk in the hour time field would be equivalent to 'every hour' 
  (subject to matching other specified fields).
* The slash ('/') operator (called "step") can be used to skip a given number of 
  values. For example, "*/3" in the hour time field is equivalent to 
  "0,3,6,9,12,15,18,21".

3. EXAMPLES
---------------------------------

 */15 * * * : Execute job every 15 minutes
 0 2,14 * * *: Execute job every day at 2:00 and 14:00
 0 2 * * 1-5: Execute job at 2:00 of every working day
 0 12 1 */2 1: Execute job every 2 month, at 12:00 of first day of the month OR
 at every monday.

4. SCRIPTS
---------------------------------

You can use the script section to easily create new jobs (by calling a php 
function) or to change the scheduling of an existing job.

Every line of the script can be a comment (if it starts with #) or a job 
definition.

The syntax of a job definition is:
<-> [rule] <ctx:CONTEXT> [job]

(Tokens betweens [] are mandatory)

* <->: a line starting with "-" means that the job is DISABLED.
* [rule]: a crontab schedule rule. See above.
* <ctx:CHANNEL>: set the channel of the task.
* [job]: could be the name of a supported job (for example: 'search_cron') or a
  function call, ending with ; (for example: 'process_queue();').

A comment on the line just preceding a job definition is considered the job 
description.

Remember that script OVERRIDES all settings on single jobs sections or channel 
sections of the configuration

5. EXAMPLE OF SCRIPT
---------------------------------

# Search indexing every 2 hours (i'm setting this as the job description)
0 */2 * * * search_cron

# I'll check for module status only on sunday nights 
# (and this is will not be the job description, see the empty line below)

0 2 * * 0 update_status_cron

# Trackback ping process every 15min and on a channel called "net"
*/15 * * * * ctx:net trackback_cron

# Disable node_cron (i must set the cron rule even if disabled)
- */15 * * * * node_cron

# Launch function send_summary_mail('test@test.com', false); every night
# And set its description to "Send daily summary"
# Send daily summary
0 1 * * *  send_summary_mail('test@test.com', false);

-----------------------------------------------------------------------------
CREDITS
-----------------------------------------------------------------------------

Elysia cron is a part of the Elysia project (but could be used stand alone
with no limitation).

Developing is sponsored by :
Void Labs s.n.c
http://www.void.it

File

README.txt
View source
  1. ELYSIA_CRON
  2. by Eric Berdondini (gotheric)
  3. For installation instructions read INSTALL.TXT
  4. For module developers API documetation read API.TXT
  5. -----------------------------------------------------------------------------
  6. FEATURES
  7. -----------------------------------------------------------------------------
  8. Elysia Cron extends Drupal standard cron, allowing a fine grain control over
  9. each task and several ways to add custom cron jobs to your site.
  10. - Set the timings and frequencies of each cron task (you can run some jobs every
  11. day at a specified hour, other only monthly and so on...).
  12. For each task you can simply choose between some frequently used options
  13. ("once a day", "once a month" ...), or use a powerful "linux crontab"-like
  14. syntax to set the accurate timings. You can even define your frequently used
  15. options to speed up site configuration.
  16. - Parallel execution of cron task: you can group jobs in channels and execute
  17. then simultaneously: so a task that takes a lot of time to execute won't block
  18. other tasks that need to be executed every 5 minutes...
  19. - You can disable all tasks, an entire channel or a single task.
  20. - Change the priority/order of task execution.
  21. - Manual force the execution of a cron tasks.
  22. - Detailed overview of cron status with time statistics for single tasks and
  23. channels.
  24. - Powerful API for module developers: you can define extra cron tasks for your
  25. modules, each one with own default timings (site administrators can override
  26. them by configuration, other modules via hook_alter). Elysia Cron 2.0 gives a
  27. brand new API support (compatible with 1.0 version) with a lot of features.
  28. - Administrators can define custom jobs (call to functions with parameters), via
  29. the "script" option.
  30. - Several optimization for frequent cron calls and error handling.
  31. - Protection from external cron calling by cron_key or allowed host list.
  32. Elysia has no dependencies with contributed modules, and doesn't need to patch
  33. the core: it can be used in minimal Drupal installation with only core modules.
  34. It also can be used in a Drupal install profile.
  35. 3rd party integration:
  36. - Ping feature, for external tracking services like host-tracker to tell whether
  37. cron is functioning properly on your site.
  38. - Drush support: you can call "drush elysia-cron" to manually run extended cron.
  39. - CTools support for exports/backup of task settings.
  40. - Features support.
  41. -----------------------------------------------------------------------------
  42. USAGE EXAMPLES
  43. -----------------------------------------------------------------------------
  44. Elysia cron is usually used in large sites that needs performance optimization.
  45. - Avoid drupal peak loads by distributing heavy load tasks during quiet periods
  46. of the day: for example you may want to rebuild the XML Sitemap of your site
  47. at 2:00AM in the morning, where usually only a few people are visiting your
  48. site. You can even move some tasks to be executed only once a month (log
  49. rotation, old records expiry...).
  50. - If you have tasks that should be executed very often, but don't want to
  51. execute ALL drupal cron tasks that often! For example, you may want to check
  52. for emails that needs to be sent to your users every 2 minutes. Standard cron
  53. is managed in a "monolithic" way, so even if you find out how to execute it
  54. every 2 minutes, you will end in having all cron tasks executed so often, with
  55. a lot of performance problems.
  56. - Fine tune cron cache management : drupal cron will invalidate variable cache
  57. every cron run, and this is a great performance problem if you have a
  58. frequently called task. Elysia cron optimize cache management, and doesn't
  59. need to invalidate cache.
  60. - Setup tasks that should be run at a precise time: for example if you want to
  61. send a SimpleNews newsletter every monday at 9:00AM, you can do it.
  62. - Parallel execution: if you have a task that takes a lot of time to execute,
  63. you can setup a different channel for it so it won't block other tasks that
  64. need to be executed every 5 minutes.
  65. - Turn off (disable) a cron task/feature you don't need.
  66. - Debug system cron problems. If your cron does not terminate correctly you can
  67. use extended logging, see at each cron timings and disable task to track down
  68. the problem.
  69. -----------------------------------------------------------------------------
  70. CHANNELS
  71. -----------------------------------------------------------------------------
  72. Channels are groups of tasks. Each channel is a "parallel line" of execution
  73. (= multiple channels can be executed simultaneously).
  74. Tasks inside a channel will be executed sequentially (if they should).
  75. WARNING: It's not recommended to create more than 2 or 3 channels.
  76. Every channel will increase the delay between each cron check (of the same
  77. channel), because each cron call will cycle between all channels.
  78. So, for example:
  79. If you have 1 channel it will be checked once a minute.
  80. If you have 2 channel each one will be checked every 2 minutes (almost usually,
  81. when the other one is running it will be checked once a minute).
  82. It you have 10 channels there will be a check every 10 minutes... if you have
  83. a job that should be executed every 5 minutes it won't do so!
  84. -----------------------------------------------------------------------------
  85. EXPORT VIA CTOOLS/FEATURES MODULE
  86. -----------------------------------------------------------------------------
  87. With 2.0 version of Elysia Cron you can use "Bulk Export" functionality of
  88. "Chaos Tools Suite" to export cron settings.
  89. To use it simply enable all modules, go to Structure > Bulk Exporter and
  90. select the tasks you want to export settings. You can also select all
  91. "elysia_cron" prefixed variables to export global options.
  92. Than generate the module.
  93. The generated code will set the new defaults of elysia cron settings. This way
  94. you can simply enable it to use them, but you are free to override them in
  95. the future using the normal settings page.
  96. Note that if you want to delete all overrides, and return to exported settings,
  97. you should do a "reset to defaults" from elysia cron settings page.
  98. You can also use "Features" module to create a Feature module will the settings
  99. you need.
  100. Note that if you want to delete the overridden settings it's preferable to use
  101. the "reset to defaults" elysia cron's button.
  102. You can use the "Revert components" Features's button, but this will reset also
  103. all cron statistics (if you are not interested in them you can freely use that
  104. button).
  105. -----------------------------------------------------------------------------
  106. DRUSH SUPPORT
  107. -----------------------------------------------------------------------------
  108. Elysia Cron 2.0 adds a simple support for Drush module.
  109. You can execute the "elysia-cron" command to run cron.
  110. -----------------------------------------------------------------------------
  111. RULES AND SCRIPT SYNTAX
  112. -----------------------------------------------------------------------------
  113. 1. FIELDS ORDER
  114. ---------------------------------
  115. +---------------- minute (0 - 59)
  116. | +------------- hour (0 - 23)
  117. | | +---------- day of month (1 - 31)
  118. | | | +------- month (1 - 12)
  119. | | | | +---- day of week (0 - 6) (Sunday=0)
  120. | | | | |
  121. * * * * *
  122. Each of the patterns from the first five fields may be either * (an asterisk),
  123. which matches all legal values, or a list of elements separated by commas
  124. (see below).
  125. For "day of the week" (field 5), 0 is considered Sunday, 6 is Saturday (7 is
  126. an illegal value)
  127. A job is executed when the time/date specification fields all match the current
  128. time and date. There is one exception: if both "day of month" and "day of week"
  129. are restricted (not "*"), then either the "day of month" field (3) or the "day
  130. of week" field (5) must match the current day (even though the other of the two
  131. fields need not match the current day).
  132. 2. FIELDS OPERATOR
  133. ---------------------------------
  134. There are several ways of specifying multiple date/time values in a field:
  135. * The comma (',') operator specifies a list of values, for example: "1,3,4,7,8"
  136. * The dash ('-') operator specifies a range of values, for example: "1-6", which
  137. is equivalent to "1,2,3,4,5,6"
  138. * The asterisk ('*') operator specifies all possible values for a field. For
  139. example, an asterisk in the hour time field would be equivalent to 'every hour'
  140. (subject to matching other specified fields).
  141. * The slash ('/') operator (called "step") can be used to skip a given number of
  142. values. For example, "*/3" in the hour time field is equivalent to
  143. "0,3,6,9,12,15,18,21".
  144. 3. EXAMPLES
  145. ---------------------------------
  146. */15 * * * : Execute job every 15 minutes
  147. 0 2,14 * * *: Execute job every day at 2:00 and 14:00
  148. 0 2 * * 1-5: Execute job at 2:00 of every working day
  149. 0 12 1 */2 1: Execute job every 2 month, at 12:00 of first day of the month OR
  150. at every monday.
  151. 4. SCRIPTS
  152. ---------------------------------
  153. You can use the script section to easily create new jobs (by calling a php
  154. function) or to change the scheduling of an existing job.
  155. Every line of the script can be a comment (if it starts with #) or a job
  156. definition.
  157. The syntax of a job definition is:
  158. <-> [rule] [job]
  159. (Tokens betweens [] are mandatory)
  160. * <->: a line starting with "-" means that the job is DISABLED.
  161. * [rule]: a crontab schedule rule. See above.
  162. * : set the channel of the task.
  163. * [job]: could be the name of a supported job (for example: 'search_cron') or a
  164. function call, ending with ; (for example: 'process_queue();').
  165. A comment on the line just preceding a job definition is considered the job
  166. description.
  167. Remember that script OVERRIDES all settings on single jobs sections or channel
  168. sections of the configuration
  169. 5. EXAMPLE OF SCRIPT
  170. ---------------------------------
  171. # Search indexing every 2 hours (i'm setting this as the job description)
  172. 0 */2 * * * search_cron
  173. # I'll check for module status only on sunday nights
  174. # (and this is will not be the job description, see the empty line below)
  175. 0 2 * * 0 update_status_cron
  176. # Trackback ping process every 15min and on a channel called "net"
  177. */15 * * * * ctx:net trackback_cron
  178. # Disable node_cron (i must set the cron rule even if disabled)
  179. - */15 * * * * node_cron
  180. # Launch function send_summary_mail('test@test.com', false); every night
  181. # And set its description to "Send daily summary"
  182. # Send daily summary
  183. 0 1 * * * send_summary_mail('test@test.com', false);
  184. -----------------------------------------------------------------------------
  185. CREDITS
  186. -----------------------------------------------------------------------------
  187. Elysia cron is a part of the Elysia project (but could be used stand alone
  188. with no limitation).
  189. Developing is sponsored by :
  190. Void Labs s.n.c
  191. http://www.void.it