cron.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * Scheduled jobs entry point
  4. *
  5. * Copyright © Magento, Inc. All rights reserved.
  6. * See COPYING.txt for license details.
  7. */
  8. use Magento\Store\Model\Store;
  9. use Magento\Store\Model\StoreManager;
  10. require dirname(__DIR__) . '/app/bootstrap.php';
  11. if (php_sapi_name() === 'cli') {
  12. echo "You cannot run this from the command line." . PHP_EOL .
  13. "Run \"php bin/magento cron:run\" instead." . PHP_EOL;
  14. exit(1);
  15. } else {
  16. $opt = $_GET;
  17. }
  18. try {
  19. foreach ($opt as $key => $value) {
  20. $opt[$key] = escapeshellarg($value);
  21. }
  22. $opt['standaloneProcessStarted'] = '0';
  23. $params = $_SERVER;
  24. $params[StoreManager::PARAM_RUN_CODE] = 'admin';
  25. $params[Store::CUSTOM_ENTRY_POINT_PARAM] = true;
  26. $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $params);
  27. /** @var \Magento\Framework\App\Cron $app */
  28. $app = $bootstrap->createApplication(\Magento\Framework\App\Cron::class, ['parameters' => $opt]);
  29. $bootstrap->run($app);
  30. } catch (\Exception $e) {
  31. echo $e;
  32. exit(1);
  33. }