// Delete jobs
if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->delete) {
    //Delete cron task
    $object = new Cronjob($db);
    $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 = '';
        }
示例#2
0
if (is_array($object->lines) && count($object->lines) > 0) {
    // Loop over job
    foreach ($object->lines as $line) {
        dol_syslog("cron_run_jobs.php fetch cronjobid: " . $line->id, LOG_WARNING);
        //If date_next_jobs is less of current dat, execute the program, and store the execution time of the next execution in database
        if ($line->datenextrun <= $now && $line->dateend < $now || empty($line->datenextrun) && empty($line->dateend)) {
            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;
            }
        }
示例#3
0
if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->delete) {
    //Delete cron task
    $object = new Cronjob($db);
    $object->id = $id;
    $result = $object->delete($user);
    if ($result < 0) {
        setEventMessages($object->error, $object->errors, 'errors');
    }
}
// Execute jobs
if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute) {
    $object = new Cronjob($db);
    $job = $object->fetch($id);
    $now = dol_now();
    // Date we start
    $resrunjob = $object->run_jobs($user->login);
    // Return -1 if KO, 1 if OK
    if ($resrunjob < 0) {
        setEventMessages($object->error, $object->errors, 'errors');
    }
    // Programm next run
    $res = $object->reprogram_jobs($user->login, $now);
    if ($res > 0) {
        if ($resrunjob >= 0) {
            if ($object->lastresult >= 0) {
                setEventMessages($langs->trans("JobFinished"), null, 'mesgs');
            } else {
                setEventMessages($langs->trans("JobFinished"), null, 'errors');
            }
        }
        $action = '';