cron.php 2.6 KB

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