cron.php 2.6 KB

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