https://www.modmore.com/extras/scheduler/documentation/scheduling-task/
is there a way to schedule a run in 10 minutes from now, only if there are no other already scheduled of the same task?
thx
----------------------------------
canale irc Italiano #modx server: tophost.azzurra.org
-
☆ A M B ☆
- 70 Posts
Hi, sure… you just need a snippet/plugin/task that does something like this:
$taskId = 1; // ENTER YOUR TASK-ID HERE
$c = $modx->newQuery('sTaskRun');
$c->where(array(
'status' => 0,
'task' => $taskId
));
$taskRuns = $modx->getCollection('sTaskRun', $c);
if (count($taskRuns) == 0) {
$task = $modx->getObject('sTask', $taskId);
$task->schedule(strtotime('+10min'));
}
The code is not tested but hopefully should work. I've used something similar before.
-
☆ A M B ☆
- 3,141 Posts
$task = $scheduler->getTask('gitifywatch', 'extract');
if ($task instanceof sTask) {
// Try to find one already scheduled
$run = $modx->getObject('sTaskRun', array(
'task' => $task->get('id'),
'status' => sTaskRun::STATUS_SCHEDULED,
));
if ($run instanceof sTaskRun) {
// already scheduled
} else {
$task->schedule($time, array(
'triggers' => array($trigger),
));
}
}
else {
$modx->log(modX::LOG_LEVEL_ERROR, 'Could not find sTask gitifywatch:extract');
}
WOW!

thanks a lot guys!!!
----------------------------------
canale irc Italiano #modx server: tophost.azzurra.org