Beispiel #1
0
            dol_syslog("cron_run_jobs.php:: torun line->datenextrun:" . dol_print_date($line->datenextrun, 'dayhourtext') . " line->dateend:" . dol_print_date($line->dateend, 'dayhourtext') . " now:" . dol_print_date($now, 'dayhourtext'));
            $cronjob = new Cronjob($db);
            $result = $cronjob->fetch($line->id);
            if ($result < 0) {
                echo "Error:" . $cronjob->error;
                dol_syslog("cron_run_jobs.php:: fetch Error" . $cronjob->error, LOG_ERR);
                exit;
            }
            // Execut job
            $result = $cronjob->run_jobs($userlogin);
            if ($result < 0) {
                echo "Error:" . $cronjob->error;
                dol_syslog("cron_run_jobs.php:: run_jobs Error" . $cronjob->error, LOG_ERR);
                $nbofjobslaunchedko++;
            } else {
                $nbofjobslaunchedok++;
            }
            // We re-program the next execution and stores the last execution time for this job
            $result = $cronjob->reprogram_jobs($userlogin);
            if ($result < 0) {
                echo "Error:" . $cronjob->error;
                dol_syslog("cron_run_jobs.php:: reprogram_jobs Error" . $cronjob->error, LOG_ERR);
                exit;
            }
        }
    }
    echo "Result: " . $nbofjobs . " jobs - " . ($nbofjobslaunchedok + $nbofjobslaunchedko) . " launched = " . $nbofjobslaunchedok . " OK + " . $nbofjobslaunchedko . " KO";
} else {
    echo "Result: No active jobs found.";
}
$db->close();
    $object->id = $id;
    $result = $object->delete($user);
    if ($result < 0) {
        setEventMessage($object->error, 'errors');
    }
}
// Execute jobs
if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute) {
    //Execute jobs
    $object = new Cronjob($db);
    $job = $object->fetch($id);
    $result = $object->run_jobs($user->login);
    if ($result < 0) {
        setEventMessage($object->error, 'errors');
    } else {
        $res = $object->reprogram_jobs($user->login);
        if ($res > 0) {
            if ($object->lastresult > 0) {
                setEventMessage($langs->trans("JobFinished"), 'warnings');
            } else {
                setEventMessage($langs->trans("JobFinished"), 'mesgs');
            }
            $action = '';
        } else {
            setEventMessage($object->error, 'errors');
            $action = '';
        }
    }
    header("Location: " . DOL_URL_ROOT . '/cron/list.php?status=-1');
    // Make a call to avoid to run twice job when using back
    exit;