Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
ddd60d1c
Commit
ddd60d1c
authored
7 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
Fix error counting in cron
parent
68b19462
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
htdocs/cron/class/cronjob.class.php
+0
-2
0 additions, 2 deletions
htdocs/cron/class/cronjob.class.php
htdocs/public/cron/cron_run_jobs.php
+15
-9
15 additions, 9 deletions
htdocs/public/cron/cron_run_jobs.php
scripts/cron/cron_run_jobs.php
+25
-10
25 additions, 10 deletions
scripts/cron/cron_run_jobs.php
with
40 additions
and
21 deletions
htdocs/cron/class/cronjob.class.php
+
0
−
2
View file @
ddd60d1c
...
@@ -439,7 +439,6 @@ class Cronjob extends CommonObject
...
@@ -439,7 +439,6 @@ class Cronjob extends CommonObject
{
{
while
(
$i
<
$num
)
while
(
$i
<
$num
)
{
{
$line
=
new
Cronjobline
();
$line
=
new
Cronjobline
();
$obj
=
$this
->
db
->
fetch_object
(
$resql
);
$obj
=
$this
->
db
->
fetch_object
(
$resql
);
...
@@ -480,7 +479,6 @@ class Cronjob extends CommonObject
...
@@ -480,7 +479,6 @@ class Cronjob extends CommonObject
$this
->
lines
[]
=
$line
;
$this
->
lines
[]
=
$line
;
$i
++
;
$i
++
;
}
}
}
}
$this
->
db
->
free
(
$resql
);
$this
->
db
->
free
(
$resql
);
...
...
This diff is collapsed.
Click to expand it.
htdocs/public/cron/cron_run_jobs.php
+
15
−
9
View file @
ddd60d1c
...
@@ -125,19 +125,25 @@ if ($result<0)
...
@@ -125,19 +125,25 @@ if ($result<0)
exit
;
exit
;
}
}
$qualifiedjobs
=
array
();
foreach
(
$object
->
lines
as
$val
)
{
if
(
!
verifCond
(
$val
->
test
))
continue
;
$qualifiedjobs
[]
=
$val
;
}
// TODO Duplicate code. This sequence of code must be shared with code into cron_run_jobs.php script.
// TODO Duplicate code. This sequence of code must be shared with code into cron_run_jobs.php script.
// current date
// current date
$now
=
dol_now
();
$now
=
dol_now
();
$nbofjobs
=
count
(
$
object
->
line
s
);
$nbofjobs
=
count
(
$
qualifiedjob
s
);
$nbofjobslaunchedok
=
0
;
$nbofjobslaunchedok
=
0
;
$nbofjobslaunchedko
=
0
;
$nbofjobslaunchedko
=
0
;
if
(
is_array
(
$
object
->
line
s
)
&&
(
count
(
$
object
->
line
s
)
>
0
))
if
(
is_array
(
$
qualifiedjob
s
)
&&
(
count
(
$
qualifiedjob
s
)
>
0
))
{
{
// Loop over job
// Loop over job
foreach
(
$
object
->
line
s
as
$line
)
foreach
(
$
qualifiedjob
s
as
$line
)
{
{
dol_syslog
(
"cron_run_jobs.php cronjobid: "
.
$line
->
id
,
LOG_WARNING
);
dol_syslog
(
"cron_run_jobs.php cronjobid: "
.
$line
->
id
,
LOG_WARNING
);
...
@@ -150,7 +156,7 @@ if (is_array($object->lines) && (count($object->lines)>0))
...
@@ -150,7 +156,7 @@ if (is_array($object->lines) && (count($object->lines)>0))
$result
=
$cronjob
->
fetch
(
$line
->
id
);
$result
=
$cronjob
->
fetch
(
$line
->
id
);
if
(
$result
<
0
)
if
(
$result
<
0
)
{
{
echo
"Error
:
"
.
$cronjob
->
error
.
"<br>
\n
"
;
echo
"Error
cronjob->fetch:
"
.
$cronjob
->
error
.
"<br>
\n
"
;
dol_syslog
(
"cron_run_jobs.php::fetch Error"
.
$cronjob
->
error
,
LOG_ERR
);
dol_syslog
(
"cron_run_jobs.php::fetch Error"
.
$cronjob
->
error
,
LOG_ERR
);
exit
;
exit
;
}
}
...
@@ -158,7 +164,7 @@ if (is_array($object->lines) && (count($object->lines)>0))
...
@@ -158,7 +164,7 @@ if (is_array($object->lines) && (count($object->lines)>0))
$result
=
$cronjob
->
run_jobs
(
$userlogin
);
$result
=
$cronjob
->
run_jobs
(
$userlogin
);
if
(
$result
<
0
)
if
(
$result
<
0
)
{
{
echo
"Error
:
"
.
$cronjob
->
error
.
"<br>
\n
"
;
echo
"Error
cronjob->run_job:
"
.
$cronjob
->
error
.
"<br>
\n
"
;
dol_syslog
(
"cron_run_jobs.php::run_jobs Error"
.
$cronjob
->
error
,
LOG_ERR
);
dol_syslog
(
"cron_run_jobs.php::run_jobs Error"
.
$cronjob
->
error
,
LOG_ERR
);
$nbofjobslaunchedko
++
;
$nbofjobslaunchedko
++
;
}
}
...
@@ -171,7 +177,7 @@ if (is_array($object->lines) && (count($object->lines)>0))
...
@@ -171,7 +177,7 @@ if (is_array($object->lines) && (count($object->lines)>0))
$result
=
$cronjob
->
reprogram_jobs
(
$userlogin
,
$now
);
$result
=
$cronjob
->
reprogram_jobs
(
$userlogin
,
$now
);
if
(
$result
<
0
)
if
(
$result
<
0
)
{
{
echo
"Error
:
"
.
$cronjob
->
error
.
"<br>
\n
"
;
echo
"Error
cronjob->reprogram_job:
"
.
$cronjob
->
error
.
"<br>
\n
"
;
dol_syslog
(
"cron_run_jobs.php::reprogram_jobs Error"
.
$cronjob
->
error
,
LOG_ERR
);
dol_syslog
(
"cron_run_jobs.php::reprogram_jobs Error"
.
$cronjob
->
error
,
LOG_ERR
);
exit
;
exit
;
}
}
...
...
This diff is collapsed.
Click to expand it.
scripts/cron/cron_run_jobs.php
+
25
−
10
View file @
ddd60d1c
...
@@ -136,15 +136,25 @@ if ($result<0)
...
@@ -136,15 +136,25 @@ if ($result<0)
exit
(
-
1
);
exit
(
-
1
);
}
}
$qualifiedjobs
=
array
();
foreach
(
$object
->
lines
as
$val
)
{
if
(
!
verifCond
(
$val
->
test
))
continue
;
$qualifiedjobs
[]
=
$val
;
}
// TODO This sequence of code must be shared with code into public/cron/cron_run_jobs.php php page.
// TODO This sequence of code must be shared with code into public/cron/cron_run_jobs.php php page.
// current date
// current date
$now
=
dol_now
();
$now
=
dol_now
();
$nbofjobs
=
count
(
$qualifiedjobs
);
$nbofjobslaunchedok
=
0
;
$nbofjobslaunchedko
=
0
;
if
(
is_array
(
$
object
->
line
s
)
&&
(
count
(
$
object
->
line
s
)
>
0
))
if
(
is_array
(
$
qualifiedjob
s
)
&&
(
count
(
$
qualifiedjob
s
)
>
0
))
{
{
// Loop over job
// Loop over job
foreach
(
$
object
->
line
s
as
$line
)
foreach
(
$
qualifiedjob
s
as
$line
)
{
{
dol_syslog
(
"cron_run_jobs.php cronjobid: "
.
$line
->
id
,
LOG_DEBUG
);
dol_syslog
(
"cron_run_jobs.php cronjobid: "
.
$line
->
id
,
LOG_DEBUG
);
echo
"cron_run_jobs.php cronjobid: "
.
$line
->
id
.
"
\n
"
;
echo
"cron_run_jobs.php cronjobid: "
.
$line
->
id
.
"
\n
"
;
...
@@ -171,7 +181,11 @@ if(is_array($object->lines) && (count($object->lines)>0))
...
@@ -171,7 +181,11 @@ if(is_array($object->lines) && (count($object->lines)>0))
echo
"At least one job failed. Go on menu Home-Setup-Admin tools to see result for each job.
\n
"
;
echo
"At least one job failed. Go on menu Home-Setup-Admin tools to see result for each job.
\n
"
;
echo
"You can also enable module Log if not yet enabled, run again and take a look into dolibarr.log file
\n
"
;
echo
"You can also enable module Log if not yet enabled, run again and take a look into dolibarr.log file
\n
"
;
dol_syslog
(
"cron_run_jobs.php::run_jobs Error "
.
$cronjob
->
error
,
LOG_ERR
);
dol_syslog
(
"cron_run_jobs.php::run_jobs Error "
.
$cronjob
->
error
,
LOG_ERR
);
exit
(
-
1
);
$nbofjobslaunchedko
++
;
}
else
{
$nbofjobslaunchedok
++
;
}
}
// we re-program the next execution and stores the last execution time for this job
// we re-program the next execution and stores the last execution time for this job
...
@@ -194,6 +208,7 @@ if(is_array($object->lines) && (count($object->lines)>0))
...
@@ -194,6 +208,7 @@ if(is_array($object->lines) && (count($object->lines)>0))
$db
->
close
();
$db
->
close
();
if
(
$nbofjobslaunchedko
)
exit
(
1
);
exit
(
0
);
exit
(
0
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment