|
|
@ -7,6 +7,7 @@
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
include_once(ROOT_PATH.'/include/semaphore.inc.php');
|
|
|
|
include_once(ROOT_PATH.'/include/semaphore.inc.php');
|
|
|
|
|
|
|
|
include_once(ROOT_PATH.'/include/define.inc.php');
|
|
|
|
include_once(ROOT_PATH . '/include/sqlwrapper.inc.php');
|
|
|
|
include_once(ROOT_PATH . '/include/sqlwrapper.inc.php');
|
|
|
|
|
|
|
|
|
|
|
|
define(TASKING_NO_RESCEDULE, 0);
|
|
|
|
define(TASKING_NO_RESCEDULE, 0);
|
|
|
@ -21,6 +22,8 @@ define(TASKING_12_HOUR, 8);
|
|
|
|
define(TASKING_DAYLY, 9);
|
|
|
|
define(TASKING_DAYLY, 9);
|
|
|
|
define(TASKING_DAY_OF_WEEK, 10);
|
|
|
|
define(TASKING_DAY_OF_WEEK, 10);
|
|
|
|
define(TASKING_DAY_OF_MONTH, 11);
|
|
|
|
define(TASKING_DAY_OF_MONTH, 11);
|
|
|
|
|
|
|
|
defineIfNotDefined('TASKING_CRONJOB_PATH', '', true); // does not have to be set when having crond-support ;)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* The method that has to be called by a cronjob!
|
|
|
|
* The method that has to be called by a cronjob!
|
|
|
@ -51,11 +54,19 @@ function tick() {
|
|
|
|
* @param int $task_id the task id that should be updated (if one only wants to update an existant job)
|
|
|
|
* @param int $task_id the task id that should be updated (if one only wants to update an existant job)
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
function schedule($script_name, array $parameters, $execution_time, $repeat_mode, $catchUpOn = false, $task_id = NULL) {
|
|
|
|
function schedule($script_name, array $parameters, $execution_time, $repeat_mode, $catchUpOn = false, $task_id = NULL) {
|
|
|
|
// FIXME: Solve the parameter problem differently ;)
|
|
|
|
// FIXME: Solve the parameter problem differently
|
|
|
|
|
|
|
|
// as it is not yet clear how to start a multi command transaction do it the dirty way here and solve it in the right way later
|
|
|
|
|
|
|
|
// so please do not hate me Jester and don't tell my mum ;)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$parameters_string = '';
|
|
|
|
|
|
|
|
foreach($parameters as $key => $value){
|
|
|
|
|
|
|
|
$parameters_string .= $key .'='.$value.' ';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if($task_id === NULL) {
|
|
|
|
if($task_id === NULL) {
|
|
|
|
db_query('INSERT INTO tasking(script_name, parameter, schedule_time, mode, catchup) values(\''.$script_name.'\', \''.implode(',', $parameters).'\', \''.$execution_time.'\', \''.$repeat_mode.'\', \''.$catchUpOn.'\')');
|
|
|
|
db_query('INSERT INTO tasking(script_name, parameter, schedule_time, mode, catchup) values(\''.$script_name.'\', \''.$parameters_string.'\', \''.$execution_time.'\', \''.$repeat_mode.'\', \''.$catchUpOn.'\')');
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
db_query('UPDATE tasking SET script_name = \''.$script_name.'\' , parameter = \''.implode(',', $parameters).'\', schedule_time = \''.$execution_time.'\', mode = \''.$repeat_mode.'\', catchup = \''.$catchUpOn.'\' WHERE task_id = ' . $task_id);
|
|
|
|
db_query('UPDATE tasking SET script_name = \''.$script_name.'\' , parameter = \''.$parameters_string.'\', schedule_time = \''.$execution_time.'\', mode = \''.$repeat_mode.'\', catchup = \''.$catchUpOn.'\' WHERE task_id = ' . $task_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -118,7 +129,17 @@ function executeScript($task_id) {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: execute the script
|
|
|
|
$path = null;
|
|
|
|
|
|
|
|
if(TASKING_CRONJOB_PATH != '') {
|
|
|
|
|
|
|
|
$path = TASKING_CRONJOB_PATH;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$path = ROOT_PATH;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exec('php5 ' . $path . '/' . $task['script_name'] . ' ' . $task['parameters'], $ausgabe);
|
|
|
|
|
|
|
|
if($ausgabe != NULL && $ausgabe != '') {
|
|
|
|
|
|
|
|
echo $ausgabe;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$time = $task['schedule_time'];
|
|
|
|
$time = $task['schedule_time'];
|
|
|
|
switch($task['mode'])
|
|
|
|
switch($task['mode'])
|
|
|
|