Some debug into cron module:
- Because cron is a module, constant must start with CRON_. - Miscellanous fixes. - For external link to run jobs from url, we must forge url using conf file and not autodetect url.
This commit is contained in:
parent
9fe0d2cdd2
commit
c3589e9785
@ -69,7 +69,7 @@ class FormCron extends Form
|
||||
}
|
||||
}else {
|
||||
|
||||
$out='<SELECT name="'.$htmlname.'" id="'.$htmlname.'" />';
|
||||
$out='<SELECT class="flat" name="'.$htmlname.'" id="'.$htmlname.'" />';
|
||||
|
||||
if ($selected=='command') {
|
||||
$selected_attr=' selected=\"selected\" ';
|
||||
|
||||
@ -15,19 +15,18 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file cron/lib/cron.lib.php
|
||||
* \brief Ensemble de fonctions de base pour le module jobs
|
||||
* \ingroup jobs
|
||||
* \brief Function for module cron
|
||||
* \ingroup cron
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return array of tabs to used on pages for third parties cards.
|
||||
* Return array of tabs to used on pages to setup cron module.
|
||||
*
|
||||
* @param Object $object Object company shown
|
||||
* @return array Array of tabs
|
||||
*/
|
||||
|
||||
function cronadmin_prepare_head()
|
||||
{
|
||||
global $langs, $conf, $user;
|
||||
@ -35,7 +34,7 @@ function cronadmin_prepare_head()
|
||||
$head = array();
|
||||
|
||||
$head[$h][0] = dol_buildpath('/cron/admin/cron.php', 1);
|
||||
$head[$h][1] = $langs->trans("CronSetup");
|
||||
$head[$h][1] = $langs->trans("Miscellanous");
|
||||
$head[$h][2] = 'setup';
|
||||
$h++;
|
||||
|
||||
@ -47,6 +46,12 @@ function cronadmin_prepare_head()
|
||||
return $head;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array of tabs to used on a cron job
|
||||
*
|
||||
* @param Object $object Object cron
|
||||
* @return array Array of tabs
|
||||
*/
|
||||
function cron_prepare_head($object)
|
||||
{
|
||||
global $langs, $conf, $user;
|
||||
@ -59,7 +64,7 @@ function cron_prepare_head($object)
|
||||
$h++;
|
||||
|
||||
$head[$h][0] = dol_buildpath('/cron/info.php', 1).'?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("CronInfoPage");
|
||||
$head[$h][1] = $langs->trans("Info");
|
||||
$head[$h][2] = 'info';
|
||||
$h++;
|
||||
|
||||
|
||||
@ -43,7 +43,7 @@ class modCron extends DolibarrModules
|
||||
|
||||
// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
|
||||
// It is used to group modules in module setup page
|
||||
$this->family = "technic";
|
||||
$this->family = "base";
|
||||
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
|
||||
$this->name = preg_replace('/^mod/i','',get_class($this));
|
||||
$this->description = "Enable the Dolibarr cron service";
|
||||
@ -72,7 +72,7 @@ class modCron extends DolibarrModules
|
||||
//-----------
|
||||
$this->const = array(
|
||||
0=>array(
|
||||
'MAIN_CRON_KEY',
|
||||
'CRON_KEY',
|
||||
'chaine',
|
||||
'',
|
||||
'CRON KEY',
|
||||
|
||||
@ -1,28 +1,28 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.org>
|
||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file cron/admin/cron.php
|
||||
* \ingroup cron
|
||||
*/
|
||||
* \ingroup cron
|
||||
*/
|
||||
|
||||
// Dolibarr environment
|
||||
$res = @include("../../main.inc.php"); // From htdocs directory
|
||||
@ -44,7 +44,7 @@ if (!empty($actionsave))
|
||||
|
||||
$db->begin();
|
||||
|
||||
$i+=dolibarr_set_const($db,'MAIN_CRON_KEY',trim(GETPOST("MAIN_CRON_KEY")),'chaine',0,'',0);
|
||||
$i+=dolibarr_set_const($db,'CRON_KEY',trim(GETPOST("CRON_KEY")),'chaine',0,'',0);
|
||||
|
||||
if ($i >= 1)
|
||||
{
|
||||
@ -61,7 +61,7 @@ if (!empty($actionsave))
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
*/
|
||||
|
||||
llxHeader();
|
||||
|
||||
@ -70,6 +70,7 @@ print_fiche_titre($langs->trans("CronSetup"),$linkback,'setup');
|
||||
|
||||
// Configuration header
|
||||
$head = cronadmin_prepare_head();
|
||||
|
||||
dol_fiche_head($head,'setup',$langs->trans("Module2300Name"),0,'cron');
|
||||
|
||||
print "<br>\n";
|
||||
@ -86,7 +87,7 @@ print "</tr>";
|
||||
|
||||
print '<tr class="impair">';
|
||||
print '<td class="fieldrequired">'.$langs->trans("KeyForCronAccess").'</td>';
|
||||
print '<td><input type="text" class="flat" id="MAIN_CRON_KEY" name="MAIN_CRON_KEY" value="'. (GETPOST('MAIN_CRON_KEY')?GETPOST('MAIN_CRON_KEY'):(! empty($conf->global->MAIN_CRON_KEY)?$conf->global->MAIN_CRON_KEY:'')) . '" size="40">';
|
||||
print '<td><input type="text" class="flat" id="CRON_KEY" name="CRON_KEY" value="'. (GETPOST('CRON_KEY')?GETPOST('CRON_KEY'):(! empty($conf->global->CRON_KEY)?$conf->global->CRON_KEY:'')) . '" size="40">';
|
||||
if (! empty($conf->use_javascript_ajax))
|
||||
print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"');
|
||||
print '</td>';
|
||||
@ -101,38 +102,42 @@ print '</center>';
|
||||
|
||||
print '</form>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
print '<br><br>';
|
||||
|
||||
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
|
||||
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
||||
|
||||
// Cron launch
|
||||
print '<u>'.$langs->trans("URLToLaunchCronJobs").':</u><br>';
|
||||
$url=dol_buildpath('/public/cron/cron_run_jobs.php',1).(empty($conf->global->MAIN_CRON_KEY)?'':'?securitykey='.$conf->global->MAIN_CRON_KEY.'&').'userlogin='.$user->login;
|
||||
$url=$urlwithroot.'/public/cron/cron_run_jobs.php'.(empty($conf->global->CRON_KEY)?'':'?securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login;
|
||||
print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
|
||||
print ' '.$langs->trans("OrToLaunchASpecificJob").'<br>';
|
||||
$url=dol_buildpath('/public/cron/cron_run_jobs.php',1).(empty($conf->global->MAIN_CRON_KEY)?'':'?securitykey='.$conf->global->MAIN_CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid';
|
||||
$url=$urlwithroot.'/public/cron/cron_run_jobs.php'.(empty($conf->global->CRON_KEY)?'':'?securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid';
|
||||
print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
|
||||
|
||||
$linuxlike=1;
|
||||
if (preg_match('/^win/i',PHP_OS)) $linuxlike=0;
|
||||
if (preg_match('/^mac/i',PHP_OS)) $linuxlike=0;
|
||||
|
||||
print '<br>';
|
||||
print '<u>'.$langs->trans("FileToLaunchCronJobs").':</u><br>';
|
||||
|
||||
$file='/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$user->login.' [cronjobid]';
|
||||
print '<textarea rows="'.ROWS_2.'" cols="120">..'.$file."</textarea><br>\n";
|
||||
print '<br>';
|
||||
print $langs->trans("Note").': ';
|
||||
if ($linuxlike) {
|
||||
print $langs->trans("CronExplainHowToRunUnix");
|
||||
} else {
|
||||
print $langs->trans("CronExplainHowToRunWin");
|
||||
}
|
||||
print '<br>';
|
||||
print '<u>'.$langs->trans("FileToLaunchCronJobs").':</u><br>';
|
||||
$file='/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->MAIN_CRON_KEY)?'securitykey':''.$conf->global->MAIN_CRON_KEY.'').' '.$user->login.' cronjobid(optionnal)';
|
||||
if ($linuxlike) {
|
||||
print 'user@host:'.DOL_DOCUMENT_ROOT.'$ php ..'.$file."<br>\n";
|
||||
} else {
|
||||
print DOL_DOCUMENT_ROOT.'> php ..'.$file."<br>\n";
|
||||
}
|
||||
print '<br>';
|
||||
|
||||
|
||||
|
||||
@ -149,7 +154,7 @@ if (! empty($conf->use_javascript_ajax))
|
||||
generic: true
|
||||
},
|
||||
function(token) {
|
||||
$("#MAIN_CRON_KEY").val(token);
|
||||
$("#CRON_KEY").val(token);
|
||||
});
|
||||
});
|
||||
});';
|
||||
|
||||
@ -42,6 +42,11 @@ $action=GETPOST('action','alpha');
|
||||
$confirm=GETPOST('confirm','alpha');
|
||||
$cancel=GETPOST('cancel');
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$object = new Cronjob($db);
|
||||
if (!empty($id)) {
|
||||
$result=$object->fetch($id);
|
||||
@ -187,16 +192,23 @@ if ($action=='inactive') {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
$formCron = new FormCron($db);
|
||||
|
||||
llxHeader('',$langs->trans("CronAdd"));
|
||||
|
||||
if ($action=='edit' || empty($action) || $action=='delete' || $action=='execute') {
|
||||
if ($action=='edit' || empty($action) || $action=='delete' || $action=='execute')
|
||||
{
|
||||
$head=cron_prepare_head($object);
|
||||
dol_fiche_head($head, 'card', $langs->trans("CronTask"), 0, 'bill');
|
||||
} elseif ($action=='create') {
|
||||
}
|
||||
elseif ($action=='create')
|
||||
{
|
||||
print_fiche_titre($langs->trans("CronTask"),'','setup');
|
||||
}
|
||||
|
||||
@ -223,9 +235,6 @@ if ($conf->use_javascript_ajax)
|
||||
print '</script>'."\n";
|
||||
}
|
||||
|
||||
$form = new Form($db);
|
||||
$formCron = new FormCron($db);
|
||||
|
||||
if ($action == 'delete')
|
||||
{
|
||||
$ret=$form->form_confirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("CronDelete"),$langs->trans("CronConfirmDelete"),"confirm_delete",'','',1);
|
||||
@ -243,9 +252,10 @@ if ($action == 'execute'){
|
||||
|
||||
/*
|
||||
* Create Template
|
||||
*/
|
||||
*/
|
||||
|
||||
if (empty($object->status)) {
|
||||
if (empty($object->status) && $action != 'create')
|
||||
{
|
||||
dol_htmloutput_mesg($langs->trans("CronTaskInactive"),'','warning',1);
|
||||
}
|
||||
|
||||
@ -253,10 +263,13 @@ if (($action=="create") || ($action=="edit")) {
|
||||
|
||||
print '<form name="cronform" action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'."\n";
|
||||
if (!empty($object->id)) {
|
||||
if (!empty($object->id))
|
||||
{
|
||||
print '<input type="hidden" name="action" value="update">'."\n";
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">'."\n";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="hidden" name="action" value="add">'."\n";
|
||||
}
|
||||
|
||||
@ -264,7 +277,7 @@ if (($action=="create") || ($action=="edit")) {
|
||||
|
||||
print '<tr><td width="30%">';
|
||||
print $langs->trans('CronLabel')."</td>";
|
||||
print "<td><input type=\"text\" size=\"20\" name=\"label\" value=\"".$object->label."\" /> ";
|
||||
print "<td><input type=\"text\" class=\"flat\" size=\"20\" name=\"label\" value=\"".$object->label."\" /> ";
|
||||
print "</td>";
|
||||
print "<td>";
|
||||
print "</td>";
|
||||
@ -318,7 +331,7 @@ if (($action=="create") || ($action=="edit")) {
|
||||
|
||||
print "<tr><td>";
|
||||
print $langs->trans('CronEvery')."</td>";
|
||||
print "<td><select name=\"nbfrequency\">";
|
||||
print "<td><select class=\"flat\" name=\"nbfrequency\">";
|
||||
for($i=1; $i<=60; $i++){
|
||||
if(($object->frequency/$object->unitfrequency) == $i){
|
||||
print "<option value='".$i."' selected='selected'>".$i."</option>";
|
||||
@ -327,7 +340,7 @@ if (($action=="create") || ($action=="edit")) {
|
||||
print "<option value='".$i."'>".$i."</option>";
|
||||
}
|
||||
}
|
||||
$input = "<input type=\"radio\" name=\"unitfrequency\" value=\"60\" id=\"frequency_minute\" ";
|
||||
$input = "<input class=\"flat\" type=\"radio\" name=\"unitfrequency\" value=\"60\" id=\"frequency_minute\" ";
|
||||
if($object->unitfrequency=="60"){
|
||||
$input .= ' checked="checked" />';
|
||||
}
|
||||
@ -337,7 +350,7 @@ if (($action=="create") || ($action=="edit")) {
|
||||
$input .= "<label for=\"frequency_minute\">".$langs->trans('Minutes')."</label>";
|
||||
print $input;
|
||||
|
||||
$input = "<input type=\"radio\" name=\"unitfrequency\" value=\"3600\" id=\"frequency_heures\" ";
|
||||
$input = "<input class=\"flat\" type=\"radio\" name=\"unitfrequency\" value=\"3600\" id=\"frequency_heures\" ";
|
||||
if($object->unitfrequency=="3600"){
|
||||
$input .= ' checked="checked" />';
|
||||
}
|
||||
@ -347,7 +360,7 @@ if (($action=="create") || ($action=="edit")) {
|
||||
$input .= "<label for=\"frequency_heures\">".$langs->trans('Hours')."</label>";
|
||||
print $input;
|
||||
|
||||
$input = "<input type=\"radio\" name=\"unitfrequency\" value=\"86400\" id=\"frequency_jours\" ";
|
||||
$input = "<input class=\"flat\" type=\"radio\" name=\"unitfrequency\" value=\"86400\" id=\"frequency_jours\" ";
|
||||
if($object->unitfrequency=="86400"){
|
||||
$input .= ' checked="checked" />';
|
||||
}
|
||||
@ -371,10 +384,9 @@ if (($action=="create") || ($action=="edit")) {
|
||||
print "</td>";
|
||||
print "</tr>\n";
|
||||
|
||||
|
||||
print '<tr class="blockmethod"><td>';
|
||||
print $langs->trans('CronModule')."</td><td>";
|
||||
print "<input type=\"text\" size=\"20\" name=\"module_name\" value=\"".$object->module_name."\" /> ";
|
||||
print "<input class=\"flat\" type=\"text\" size=\"20\" name=\"module_name\" value=\"".$object->module_name."\" /> ";
|
||||
print "</td>";
|
||||
print "<td>";
|
||||
print $form->textwithpicto('',$langs->trans("CronModuleHelp"),1,'help');
|
||||
@ -383,7 +395,7 @@ if (($action=="create") || ($action=="edit")) {
|
||||
|
||||
print '<tr class="blockmethod"><td>';
|
||||
print $langs->trans('CronClassFile')."</td><td>";
|
||||
print "<input type=\"text\" size=\"20\" name=\"classesname\" value=\"".$object->classesname."\" /> ";
|
||||
print "<input class=\"flat\" type=\"text\" size=\"20\" name=\"classesname\" value=\"".$object->classesname."\" /> ";
|
||||
print "</td>";
|
||||
print "<td>";
|
||||
print $form->textwithpicto('',$langs->trans("CronClassFileHelp"),1,'help');
|
||||
@ -392,7 +404,7 @@ if (($action=="create") || ($action=="edit")) {
|
||||
|
||||
print '<tr class="blockmethod"><td>';
|
||||
print $langs->trans('CronObject')."</td><td>";
|
||||
print "<input type=\"text\" size=\"20\" name=\"objectname\" value=\"".$object->objectname."\" /> ";
|
||||
print "<input class=\"flat\" type=\"text\" size=\"20\" name=\"objectname\" value=\"".$object->objectname."\" /> ";
|
||||
print "</td>";
|
||||
print "<td>";
|
||||
print $form->textwithpicto('',$langs->trans("CronObjectHelp"),1,'help');
|
||||
@ -401,7 +413,7 @@ if (($action=="create") || ($action=="edit")) {
|
||||
|
||||
print '<tr class="blockmethod"><td>';
|
||||
print $langs->trans('CronMethod')."</td><td>";
|
||||
print "<input type=\"text\" size=\"20\" name=\"methodename\" value=\"".$object->methodename."\" /> ";
|
||||
print "<input class=\"flat\" type=\"text\" size=\"20\" name=\"methodename\" value=\"".$object->methodename."\" /> ";
|
||||
print "</td>";
|
||||
print "<td>";
|
||||
print $form->textwithpicto('',$langs->trans("CronMethodHelp"),1,'help');
|
||||
@ -410,7 +422,7 @@ if (($action=="create") || ($action=="edit")) {
|
||||
|
||||
print '<tr class="blockmethod"><td>';
|
||||
print $langs->trans('CronArgs')."</td><td>";
|
||||
print "<input type=\"text\" size=\"20\" name=\"params\" value=\"".$object->params."\" /> ";
|
||||
print "<input class=\"flat\" type=\"text\" size=\"20\" name=\"params\" value=\"".$object->params."\" /> ";
|
||||
print "</td>";
|
||||
print "<td>";
|
||||
print $form->textwithpicto('',$langs->trans("CronArgsHelp"),1,'help');
|
||||
@ -419,7 +431,7 @@ if (($action=="create") || ($action=="edit")) {
|
||||
|
||||
print '<tr class="blockcommand"><td>';
|
||||
print $langs->trans('CronCommand')."</td><td>";
|
||||
print "<input type=\"text\" size=\"50\" name=\"command\" value=\"".$object->command."\" /> ";
|
||||
print "<input class=\"flat\" type=\"text\" size=\"50\" name=\"command\" value=\"".$object->command."\" /> ";
|
||||
print "</td>";
|
||||
print "<td>";
|
||||
print $form->textwithpicto('',$langs->trans("CronCommandHelp"),1,'help');
|
||||
@ -448,11 +460,13 @@ if (($action=="create") || ($action=="edit")) {
|
||||
|
||||
print "</form>\n";
|
||||
|
||||
}else {
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
/*
|
||||
* view Template
|
||||
*/
|
||||
*/
|
||||
|
||||
// box add_jobs_box
|
||||
print '<table class="border" width="100%">';
|
||||
@ -564,6 +578,10 @@ if (($action=="create") || ($action=="edit")) {
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
print dol_fiche_end();
|
||||
|
||||
|
||||
print "\n\n<div class=\"tabsAction\">\n";
|
||||
if (! $user->rights->cron->create) {
|
||||
print '<a class="butActionRefused" href="#" title="'.dol_escape_htmltag($langs->transnoentitiesnoconv("NotEnoughPermissions")).'">'.$langs->trans("Edit").'</a>';
|
||||
|
||||
@ -9,8 +9,8 @@ URLToLaunchCronJobs=URL pour lancer les taches automatiques
|
||||
OrToLaunchASpecificJob=Ou pour lancer une tache spécifique
|
||||
KeyForCronAccess=Clé de sécurité pour l'URL de lancement des taches automatiques
|
||||
FileToLaunchCronJobs=Commande pour lancer les taches automatiques
|
||||
CronExplainHowToRunUnix=Sur un environement Unix vous pouvez paramétré CronTab pour executer cette commande toute les minutes
|
||||
CronExplainHowToRunWin=Sur un environement Microsoft(tm) Windows vous pouvez utilisr le planificateur de tache pour lancer cette commande toute les minutes
|
||||
CronExplainHowToRunUnix=Sur un environement Unix vous pouvez paramétrer CronTab pour executer cette commande toute les minutes.
|
||||
CronExplainHowToRunWin=Sur un environement Microsoft(tm) Windows vous pouvez utiliser le planificateur de tache pour lancer cette commande toute les minutes.
|
||||
|
||||
#
|
||||
# Menu
|
||||
|
||||
@ -49,7 +49,7 @@ if (empty($key)) {
|
||||
echo 'securitykey is require';
|
||||
exit;
|
||||
}
|
||||
if($key != $conf->global->MAIN_CRON_KEY)
|
||||
if($key != $conf->global->CRON_KEY)
|
||||
{
|
||||
echo 'securitykey is wrong';
|
||||
exit;
|
||||
|
||||
|
Before Width: | Height: | Size: 655 B After Width: | Height: | Size: 655 B |
62
scripts/cron/cron_run_jobs.php
Normal file → Executable file
62
scripts/cron/cron_run_jobs.php
Normal file → Executable file
@ -27,9 +27,10 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1');
|
||||
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1');
|
||||
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
|
||||
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
|
||||
if (! defined('NOLOGIN')) define('NOLOGIN','1');
|
||||
if (! defined('NOLOGIN')) define('NOLOGIN','1');
|
||||
//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
|
||||
|
||||
|
||||
$sapi_type = php_sapi_name();
|
||||
$script_file = basename(__FILE__);
|
||||
$path=dirname(__FILE__).'/';
|
||||
@ -53,46 +54,47 @@ if (! isset($argv[2]) || ! $argv[2]) {
|
||||
$userlogin=$argv[2];
|
||||
}
|
||||
|
||||
|
||||
$res=@include("../../master.inc.php"); // For root directory
|
||||
if (! $res) $res=@include("../../../master.inc.php"); // For "custom" directory
|
||||
if (! $res) die("Include of master.inc.php fails");
|
||||
require_once ($path."../../htdocs/master.inc.php");
|
||||
require_once (DOL_DOCUMENT_ROOT."/cron/class/cronjob.class.php");
|
||||
require_once (DOL_DOCUMENT_ROOT.'/user/class/user.class.php');
|
||||
require_once (DOL_DOCUMENT_ROOT."/cron/class/cronjob.class.php");
|
||||
|
||||
|
||||
// librarie jobs
|
||||
require_once (DOL_DOCUMENT_ROOT_ALT."/cron/class/cronjob.class.php");
|
||||
/*
|
||||
* Main
|
||||
*/
|
||||
|
||||
|
||||
//Check security key
|
||||
if($key != $conf->global->MAIN_CRON_KEY)
|
||||
// Check security key
|
||||
if ($key != $conf->global->CRON_KEY)
|
||||
{
|
||||
echo 'securitykey is wrong';
|
||||
print "Error: securitykey is wrong\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
//Check user login
|
||||
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||
// Check user login
|
||||
$user=new User($db);
|
||||
$result=$user->fetch('',$userlogin);
|
||||
if ($result<0) {
|
||||
echo "User Error:".$user->error;
|
||||
if ($result < 0)
|
||||
{
|
||||
echo "User Error: ".$user->error;
|
||||
dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_ERR);
|
||||
exit;
|
||||
}else {
|
||||
if (empty($user->id)) {
|
||||
echo " User user login:".$userlogin." do not exists";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (empty($user->id))
|
||||
{
|
||||
echo " User user login: ".$userlogin." do not exists";
|
||||
dol_syslog(" User user login:".$userlogin." do not exists", LOG_ERR);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($argv[3]) || $argv[3]) {
|
||||
if (isset($argv[3]) || $argv[3])
|
||||
{
|
||||
$id = $argv[3];
|
||||
}
|
||||
|
||||
// librarie jobs
|
||||
require_once (DOL_DOCUMENT_ROOT_ALT."/cron/class/cronjob.class.php");
|
||||
|
||||
// create a jobs object
|
||||
$object = new Cronjob($db);
|
||||
|
||||
@ -103,18 +105,21 @@ if (empty($id)) {
|
||||
}
|
||||
|
||||
$result = $object->fetch_all('DESC','t.rowid', 0, 0, 1, $filter);
|
||||
if ($result<0) {
|
||||
echo "Error:".$cronjob->error;
|
||||
dol_syslog("cron_run_jobs.php:: fetch Error".$cronjob->error, LOG_ERR);
|
||||
if ($result<0)
|
||||
{
|
||||
echo "Error: ".$object->error;
|
||||
dol_syslog("cron_run_jobs.php:: fetch Error ".$object->error, LOG_ERR);
|
||||
exit;
|
||||
}
|
||||
|
||||
// current date
|
||||
$now=dol_now();
|
||||
|
||||
if(is_array($object->lines) && (count($object->lines)>0)){
|
||||
if(is_array($object->lines) && (count($object->lines)>0))
|
||||
{
|
||||
// Loop over job
|
||||
foreach($object->lines as $line){
|
||||
foreach($object->lines as $line)
|
||||
{
|
||||
|
||||
//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){
|
||||
@ -144,3 +149,6 @@ if(is_array($object->lines) && (count($object->lines)>0)){
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$db->close();
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user