Example #1
0
/**
 * File used to handle cronjob requests
 *
 * This file handles execution of multiple or single cronjobs either automatic or manually.
 *
 * @author Perfler Dominik <*****@*****.**>
 * @copyright 2014-2015 Perfler Dominik
 * @license MIT
 */
$cronjob = Lightwork::Cronjob();
// Get the cronjob
if (is_null($cronjob)) {
    $cronjobs = Lightwork::Cronjobs();
    // Get all cronjobs
    if (count($cronjobs) > 0) {
        Database::StartTransaction();
        // Start a new transaction to prevent query spam
        foreach ($cronjobs as $cronjob) {
            if (is_file(CRONJOB_DIR . $cronjob['path'] . '.php')) {
                execute($cronjob);
            } else {
                Lightwork::Log('Cronjob missing: ' . $cronjob['name']);
            }
            // ...if they exist.
        }
        Database::Commit();
        // Commit all the query timestamp updates
        Lightwork::Done(0, 'CRONJOBS_DONE');
        // We are done here, output proper exit code
    } else {
        Lightwork::Done(0, 'CRONJOBS_IDLE');