Return a list of the cron schedules sorted according to interval.

@return array The array of cron schedules. Each schedule is itself an array.
559495
protected static function get_schedules() {
		$schedules = wp_get_schedules();
		if ( ! empty( $schedules ) ) {
			uasort( $schedules, 'Cron_Schedule_Command::sort' );
			$schedules = array_map( 'Cron_Schedule_Command::format_schedule', $schedules, array_keys( $schedules ) );
		}
		return $schedules;
	}
801388
public function getAsArray()
    {
        $openingHours = [
            DayOfTheWeek::MONDAY => $this->getMonday(),
            DayOfTheWeek::TUESDAY => $this->getTuesday(),
            DayOfTheWeek::WEDNESDAY => $this->getWednesday(),
            DayOfTheWeek::THURSDAY => $this->getThursday(),
            DayOfTheWeek::FRIDAY => $this->getFriday(),
            DayOfTheWeek::SATURDAY => $this->getSaturday(),
            DayOfTheWeek::SUNDAY => $this->getSunday(),
        ];
        return $openingHours;
    }
1358039
public function toArray()
    {
        $start    = $this->intervalStart;
        $end      = $this->intervalEnd;
        $period   = new \DatePeriod($start, new \DateInterval('P1D'), $end);
        $days     = array();

        foreach ($period as $current_day) {
            $days[] = $current_day;
        }

        $days[]  = $end;

        return $days;
    }
720499
public function schedule_cron_healthcheck( $schedules ) {
		$interval = apply_filters( $this->identifier . '_cron_interval', 5 );

		if ( property_exists( $this, 'cron_interval' ) ) {
			$interval = apply_filters( $this->identifier . '_cron_interval', $this->cron_interval_identifier );
		}

		// Adds every 5 minutes to the existing schedules.
		$schedules[ $this->identifier . '_cron_interval' ] = array(
			'interval' => MINUTE_IN_SECONDS * $interval,
			'display'  => sprintf( __( 'Every %d Minutes' ), $interval ),
		);

		return $schedules;
	}
494445
public function getScheduledEvents()
    {
        $schedule = app(Schedule::class);

        $events = array_map(function ($event) {
            $e = $this->convertEvent($event);
            return [
                'schedule' => $e->expression,
                'command' => $e->getCommandName(),
                'timezone' => $e->timezone,
                'mutex' => $e->mutexName(),
                'run_in_background' => $e->runInBackground,
                'without_overlapping' => $e->withoutOverlapping,
                'on_one_server' => $e->onOneServer,
                'next_run_due' => $e->getNextRunDue($e->expression, $e->timezone),
                'next_check_due' => $e->getNextCheckDue($e->expression, $e->timezone)
            ];
        }, $schedule->events());

        return $events;
    }
1369478
public function getIntervals()
	{
		$manager = \Aimeos\MShop::create( $this->getContext(), 'attribute' );

		$search = $manager->createSearch( true );
		$expr = array(
			$search->compare( '==', 'attribute.domain', 'product' ),
			$search->compare( '==', 'attribute.type', 'interval' ),
			$search->getConditions(),
		);
		$search->setConditions( $search->combine( '&&', $expr ) );
		$search->setSlice( 0, 10000 );

		$list = [];

		foreach( $manager->searchItems( $search, ['text'] ) as $attrItem ) {
			$list[$attrItem->getCode()] = $attrItem;
		}

		return $list;
	}
814052
public function getCronjobs()
    {
        if (!$this->cronjobs) {
            $cronjobs = array();

            $results = $this->serviceLocator
                ->get('Application')
                ->getEventManager()
                ->trigger(__FUNCTION__, $this, array(
                        'cronjobs' => $cronjobs
                ));

            if ($results) {
                foreach ($results as $key => $cron) {
                    foreach ($cron as $id => $conf) {
                        $cronjobs[$id] = $conf;
                    }
                }
            }

            $this->setCronjobs($cronjobs);
        }

        return $this->cronjobs;
    }
933790
public function getSchedule()
    {
        return implode(' ', [
                $this->getScheduleMonth(),
                $this->getScheduleWeek(),
                $this->getScheduleDayOfMonth(),
                $this->getScheduleDayOfWeek(),
                $this->getScheduleHour(),
                $this->getScheduleMinute()
            ]);
    }
872345
public function skipMissedSchedules()
    {
        $schedules = Mage::getModel('cron/schedule')->getCollection()
            ->addFieldToFilter('status', Aoe_Scheduler_Model_Schedule::STATUS_PENDING)
            ->addFieldToFilter('scheduled_at', array('lt' => strftime('%Y-%m-%d %H:%M:%S', time())))
            ->addOrder('scheduled_at', 'DESC')
            ->load();

        Mage::getSingleton('cron/schedule')->getResource()->beginTransaction(TRUE);
        try {
            $seenJobs = array();
            foreach ($schedules as $key => $schedule) {
                /* @var Aoe_Scheduler_Model_Schedule $schedule */
                if (isset($seenJobs[$schedule->getJobCode()])) {
                    $schedule
                        ->setMessages('Multiple tasks with the same job code were piling up. Skipping execution of duplicates.')
                        ->setStatus(Aoe_Scheduler_Model_Schedule::STATUS_SKIP_PILINGUP);
                    $updated = $schedule->getResource()->trySetJobStatusAtomic(
                        $schedule->getId(),
                        $schedule->getStatus(),
                        Aoe_Scheduler_Model_Schedule::STATUS_PENDING
                    );
                    if ($updated) {
                        $schedule->save();
                    }
                } else {
                    $seenJobs[$schedule->getJobCode()] = 1;
                }
            }
            Mage::getSingleton('cron/schedule')->getResource()->commit();
        } catch (Exception $e) {
            Mage::getSingleton('cron/schedule')->getResource()->rollBack();
            throw $e;
        }

        return $this;
    }
775458
public function getScheduleDelay()
    {
        $value = $this->getSchedule();
        if (null === $value) {
            return -1;
        }

        $object = CronExpression::factory($value);

        $format = 'Y-m-d H:i:s';
        $timeFirst = strtotime($object->getNextRunDate()->format($format));
        $timeSecond = strtotime(date($format));

        return (int) $timeFirst - $timeSecond;
    }
941610
public static function getTimeZones()
    {
        $timezones = [];

        foreach (DateTimeZone::listIdentifiers() as $timezone) {
            $timezones[$timezone] = str_replace('_', ' ', $timezone);
        }

        return $timezones;
    }
978938
public function getCronCommand()
    {
        $phpBinaryFinder = new PhpExecutableFinder();
        $php = $phpBinaryFinder->find();
        $command = 'cd ' . str_replace(' ', '\ ', GRAV_ROOT) . ';' . $php . ' bin/grav scheduler';

        return "(crontab -l; echo \"* * * * * {$command} 1>> /dev/null 2>&1\") | crontab -";
    }
101261
public function deleteAll()
    {
        /* @var $schedules Mage_Cron_Model_Resource_Schedule_Collection */
        $schedules = Mage::getModel('cron/schedule')->getCollection();
        foreach ($schedules as $key => $schedule) { /* @var Aoe_Scheduler_Model_Schedule $schedule */
            $schedule->delete();
        }
        Mage::app()->saveCache(0, Mage_Cron_Model_Observer::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT, array('crontab'), null);
        return $this;
    }
262713
public function runScheduledTasks()
    {
        $now = time();

        // Currently, there are no hourly tasks. When there are some,
        // this could be too aggressive minimum interval (some hours would be skipped in case of low traffic)
        $minimumInterval = TrackerConfig::getConfigValue('scheduled_tasks_min_interval');

        // If the user disabled browser archiving, he has already setup a cron
        // To avoid parallel requests triggering the Scheduled Tasks,
        // Get last time tasks started executing
        $cache = Cache::getCacheGeneral();

        if ($minimumInterval <= 0
            || empty($cache['isBrowserTriggerEnabled'])
        ) {
            Common::printDebug("-> Scheduled tasks not running in Tracker: Browser archiving is disabled.");
            return;
        }

        $nextRunTime = $cache['lastTrackerCronRun'] + $minimumInterval;

        if ((defined('DEBUG_FORCE_SCHEDULED_TASKS') && DEBUG_FORCE_SCHEDULED_TASKS)
            || $cache['lastTrackerCronRun'] === false
            || $nextRunTime < $now
        ) {
            $cache['lastTrackerCronRun'] = $now;
            Cache::setCacheGeneral($cache);

            Option::set('lastTrackerCronRun', $cache['lastTrackerCronRun']);
            Common::printDebug('-> Scheduled Tasks: Starting...');

            $invokeScheduledTasksUrl = "?module=API&format=csv&convertToUnicode=0&method=CoreAdminHome.runScheduledTasks&trigger=archivephp";

            $cliMulti = new CliMulti();
            $cliMulti->runAsSuperUser();
            $responses = $cliMulti->request(array($invokeScheduledTasksUrl));
            $resultTasks = reset($responses);

            Common::printDebug($resultTasks);

            Common::printDebug('Finished Scheduled Tasks.');
        } else {
            Common::printDebug("-> Scheduled tasks not triggered.");
        }

        Common::printDebug("Next run will be from: " . date('Y-m-d H:i:s', $nextRunTime) . ' UTC');
    }
402673
public function getSchedule()
    {
        /**
         * Default: get the current term schedule data by GET
         * If you want to get the other term's data, use POST
         * TODO: use POST to get other term's data
         */
        $response = $this->buildGetRequest(self::ZF_SCHEDULE_URI, [], $this->headers);
        return $this->parserSchedule($response->getBody());
    }
639883
public static function getAll()
    {
        $timezones = [];
        $identifiers = DateTimeZone::listIdentifiers();
        foreach ($identifiers as $identifier) {
            $date = new DateTime("now", new DateTimeZone($identifier));
            $offsetText = $date->format("P");
            $offsetInHours = $date->getOffset() / 60 / 60;
            $timezones[] = [
                "identifier" => $identifier,
                "name" => "(GMT{$offsetText}) $identifier",
                "offset" => $offsetInHours
            ];
        }

        ArrayHelper::multisort($timezones, "offset", SORT_ASC, SORT_NUMERIC);
        return $timezones;
    }
184596
public function generateSchedules()
    {
        /**
         * check if schedule generation is needed
         */
        $lastRun = Mage::app()->loadCache(Mage_Cron_Model_Observer::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT);
        if ($lastRun > time() - Mage::getStoreConfig(Mage_Cron_Model_Observer::XML_PATH_SCHEDULE_GENERATE_EVERY) * 60) {
            return $this;
        }

        $startTime = microtime(true);

        /* @var $jobs Aoe_Scheduler_Model_Resource_Job_Collection */
        $jobs = Mage::getSingleton('aoe_scheduler/job')->getCollection();
        $jobs->setActiveOnly(true);
        foreach ($jobs as $job) {
            /* @var Aoe_Scheduler_Model_Job $job */
            $this->generateSchedulesForJob($job);
        }

        /**
         * save time schedules generation was ran with no expiration
         */
        Mage::app()->saveCache(time(), Mage_Cron_Model_Observer::CACHE_KEY_LAST_SCHEDULE_GENERATE_AT, array('crontab'), null);

        $this->deleteDuplicates();

        if ($logFile = Mage::getStoreConfig('system/cron/logFile')) {
            $history = Mage::getModel('cron/schedule')->getCollection()
                ->setPageSize(1)
                ->setOrder('scheduled_at', 'desc')
                ->load();

            $newestSchedule = $history->getFirstItem(); /* @var $newestSchedule Aoe_Scheduler_Model_Schedule */

            $duration = microtime(true) - $startTime;
            Mage::log('Generated schedule. Newest task is scheduled at "' . $newestSchedule->getScheduledAt() . '". (Duration: ' . round($duration, 2) . ' sec)', null, $logFile);
        }

        return $this;
    }