BxDolCron.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php defined('BX_DOL') or die('hack attempt');
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaCore UNA Core
  7. * @{
  8. */
  9. /**
  10. * BxDolCron is parent class for all cron jobs, except the cases when the code is evaluated directly.
  11. *
  12. * periodic/cron.php file is used for cron jobs. It is started every minute and run cron jobs.
  13. * The file runs jobs at regular intervals, the jobs are listed in `sys_cron_jobs` table.
  14. *
  15. * Fields shark_cron_jobs table:
  16. * id - key for the table
  17. * name - job name to be executed
  18. * time - format of entries are five fields of numbers specifying the minute,
  19. * hour, day of the month, month and day of the week that a task must be executed.
  20. * @code
  21. * * * * * *
  22. * | | | | |
  23. * | | | | +--- day of week(0-6 with 0=Sunday)
  24. * | | | +----- month(1-12)
  25. * | | +------- day of month(1-31)
  26. * | +--------- hour(0-23)
  27. * +----------- minute(0-59)
  28. * @endcode
  29. *
  30. * class - class name which will run
  31. * file - path to class file
  32. * service_call - serialized service call which will be run
  33. *
  34. * The time numbers can be given as a comma separated list of simple numbers,
  35. * ranges("2-5" is the same as "2,3,4,5"). A single "*" can be used in a field to indicate all
  36. * valid numbers in that field, so it translates to "always". If a given time is valid in all five
  37. * fields then a module function is executed. Here are a few examples that illustrate the possibilities:
  38. *
  39. * @code
  40. * will run at 16:10:
  41. * 10 16
  42. * will run at 2:00 on saturday:
  43. * 0 2 * * 6
  44. * will run at midnight on new years:
  45. * 0 0 1 1 0
  46. * will run every 15 minutes:
  47. * *\/15
  48. * will run at 22:00 on work weekdays:
  49. * 0 22 * * 1-5
  50. * will run each 23 minutes, 2:00, 4:00 ..., everyday
  51. * 23 0-23/2
  52. * @endcode
  53. *
  54. * Example add new cron job:
  55. *
  56. * 1. Create new class inherited from "BxDolCron" and add method "processing"
  57. *
  58. * @code
  59. * class BxDolCronMy extends BxDolCron {
  60. *
  61. * function processing()
  62. * {
  63. * // insert code
  64. * }
  65. * }
  66. * @endcode
  67. *
  68. * 2. Add record in `sys_cron_jobs` table
  69. *
  70. * @see an example of BxDolCronPruning, BxDolCronStorage.
  71. *
  72. *
  73. * Memberships/ACL:
  74. * Doesn't depend on user's membership.
  75. *
  76. *
  77. * Alerts:
  78. * no alerts available
  79. *
  80. */
  81. abstract class BxDolCron extends BxDol
  82. {
  83. public function __construct()
  84. {
  85. parent::__construct();
  86. }
  87. abstract public function processing();
  88. }
  89. /** @} */