Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
ISPConfig 3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jakub Blažej
ISPConfig 3
Commits
b34b1ad5
Commit
b34b1ad5
authored
4 years ago
by
Till Brehm
Browse files
Options
Downloads
Patches
Plain Diff
Improved cron debug script
parent
666d1df8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/cron_debug.php
+22
-5
22 additions, 5 deletions
server/cron_debug.php
with
22 additions
and
5 deletions
server/cron_debug.php
+
22
−
5
View file @
b34b1ad5
...
@@ -39,20 +39,25 @@ ini_set('error_reporting', E_ALL & ~E_NOTICE);
...
@@ -39,20 +39,25 @@ ini_set('error_reporting', E_ALL & ~E_NOTICE);
$conf
[
'server_id'
]
=
intval
(
$conf
[
'server_id'
]);
$conf
[
'server_id'
]
=
intval
(
$conf
[
'server_id'
]);
// Load required base-classes
// Load required base-classes
$app
->
uses
(
'
modules,plugins,
ini_parser,file,services,getconf,system,cron,functions'
);
$app
->
uses
(
'ini_parser,file,services,getconf,system,cron,functions'
);
$app
->
load
(
'libdatetime,cronjob'
);
$app
->
load
(
'libdatetime,cronjob'
);
// Path settings
// Path settings
$path
=
SCRIPT_PATH
.
'/lib/classes/cron.d'
;
$path
=
SCRIPT_PATH
.
'/lib/classes/cron.d'
;
//** Get commandline options
//** Get commandline options
$cmd_opt
=
getopt
(
''
,
array
(
'cronjob::'
));
$cmd_opt
=
getopt
(
''
,
array
(
'cronjob::'
,
'force'
,
'firstrun'
));
if
(
isset
(
$cmd_opt
[
'cronjob'
])
&&
is_file
(
$path
.
'/'
.
$cmd_opt
[
'cronjob'
]))
{
if
(
isset
(
$cmd_opt
[
'cronjob'
])
&&
is_file
(
$path
.
'/'
.
$cmd_opt
[
'cronjob'
]))
{
// Cronjob that shell be run
// Cronjob that shell be run
$cronjob_file
=
$cmd_opt
[
'cronjob'
];
$cronjob_file
=
$cmd_opt
[
'cronjob'
];
}
else
{
}
else
{
die
(
'Usage example: php cron_debug.php --cronjob=100-mailbox_stats.inc.php'
);
echo
"Usage example: php cron_debug.php --cronjob=100-mailbox_stats.inc.php [--force] [--firstrun]
\n
"
;
echo
"Available cronjobs:
\n
"
;
foreach
(
glob
(
$path
.
'/*-*.inc.php'
)
as
$cronjob
)
{
echo
basename
(
$cronjob
)
.
"
\n
"
;
}
die
();
}
}
// Load and run the cronjob
// Load and run the cronjob
...
@@ -61,8 +66,20 @@ if(preg_match('/^\d+\-(.*)$/', $name, $match)) $name = $match[1]; // strip numer
...
@@ -61,8 +66,20 @@ if(preg_match('/^\d+\-(.*)$/', $name, $match)) $name = $match[1]; // strip numer
include
$path
.
'/'
.
$cronjob_file
;
include
$path
.
'/'
.
$cronjob_file
;
$class_name
=
'cronjob_'
.
$name
;
$class_name
=
'cronjob_'
.
$name
;
$cronjob
=
new
$class_name
();
$cronjob
=
new
$class_name
();
$cronjob
->
run
(
true
);
if
(
isset
(
$cmd_opt
[
'force'
]))
{
$app
->
db
->
query
(
"UPDATE `sys_cron` SET `running` = 0 WHERE `name` = ?"
,
$class_name
);
}
$cronjob
->
onPrepare
();
$cronjob
->
onBeforeRun
(
isset
(
$cmd_opt
[
'firstrun'
]));
if
(
!
$cronjob
->
isRunning
())
{
$app
->
db
->
query
(
"UPDATE `sys_cron` SET `running` = ? WHERE `name` = ?"
,
(
$cronjob
->
canBeRunInParallel
()
!==
true
?
"1"
:
"0"
),
$class_name
);
$cronjob
->
onRunJob
();
$cronjob
->
onAfterRun
();
$cronjob
->
onCompleted
();
}
die
(
"finished.
\n
"
);
die
(
"finished.
\n
"
);
?>
?>
\ No newline at end of file
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