cron.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /* For license terms, see /license.txt */
  3. exit;
  4. /**
  5. * This script should be called by a properly set cron process on your server.
  6. * For more information, check the installation guide in the documentation
  7. * folder.
  8. * Add your own executable scripts below the inclusion of notification.php
  9. * @package chamilo.cron
  10. */
  11. /**
  12. * Settings that will influence the execution of the cron tasks
  13. */
  14. //ini_set('max_execution_time',300); //authorize execution for up to 5 minutes
  15. //ini_set('memory_limit','100M'); //authorize script to use up to 100M RAM
  16. /**
  17. * Included cron-ed tasks. You might want to turn error-logging off by
  18. * commenting the first and last line of this section.
  19. */
  20. define('CLI_SCRIPT', true); // for chamilo imported code
  21. define('CHAMILO_INTERNAL', true);
  22. global $CLI_VCHAMILO_PRECHECK;
  23. $CLI_VCHAMILO_PRECHECK = true; // force first config to be minimal
  24. require(dirname(dirname(dirname(__DIR__))).'/main/inc/conf/configuration.php'); // get boot config
  25. require_once($_configuration['root_sys'].'plugin/vchamilo/cli/clilib.php'); // cli only functions
  26. // Ensure errors are well explained
  27. // now get cli options
  28. list($options, $unrecognized) = cli_get_params(
  29. array(
  30. 'help' => false,
  31. 'host' => false,
  32. ),
  33. array(
  34. 'h' => 'help',
  35. 'H' => 'host'
  36. )
  37. );
  38. if ($unrecognized) {
  39. $unrecognized = implode("\n ", $unrecognized);
  40. cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
  41. }
  42. if ($options['help']) {
  43. $help =
  44. "Command line chamilo CRON
  45. Options:
  46. -h, --help Print out this help
  47. -H, --host Set the host (physical or virtual) to operate on
  48. "; //TODO: localize - to be translated later when everything is finished
  49. echo $help;
  50. die;
  51. }
  52. if (!empty($options['host'])) {
  53. // arms the vchamilo switching
  54. echo('Arming for '.$options['host']."\n"); // mtrace not yet available.
  55. define('CLI_VCHAMILO_OVERRIDE', $options['host']);
  56. }
  57. // replay full config whenever. If vchamilo switch is armed, will switch now config
  58. require($_configuration['root_sys'].'main/inc/conf/configuration.php'); // do REALLY force configuration to play again, or the following call will not have config twicked (require_once)
  59. echo('Config check : playing for '.$_configuration['root_web']."\n");
  60. error_log('[chamilo][cronjob] Starting cron jobs as process '.getmypid());
  61. echo '<pre>';
  62. echo ('[chamilo][cronjob] Starting cron jobs as process '.getmypid()."\n");
  63. require_once $_configuration['root_sys'].'main/cron/notification.php';
  64. error_log('[chamilo][cronjob] Ending cron jobs of process '.getmypid());
  65. echo('[chamilo][cronjob] Ending cron jobs of process '.getmypid()."\n");
  66. echo '</pre>';