-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOnceADayJobs.php
More file actions
52 lines (40 loc) · 1.5 KB
/
OnceADayJobs.php
File metadata and controls
52 lines (40 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
* @license http://opensource.org/licenses/MIT MIT
*/
namespace Rdb\Modules\RdbAdmin\CronJobs;
/**
* Cron jobs that run once a day.
*
* @since 0.1
*/
class OnceADayJobs extends BaseCronJobs
{
/**
* {@inheritDoc}
*/
public function execute(): bool
{
// crontab format is 'minute' 'hour' 'day of month' 'month' 'day of week'
// 0-15 for minute unit is start at 0 minute but can delay for 15 minutes.
$CronExpression = new \Cron\CronExpression('0-15 0 * * *', new \Cron\FieldFactory());
if ($CronExpression->isDue() && !$this->Cron->hasRun()) {
// if cron job is due and never run before.
// execute the jobs in Jobs folder.
Jobs\DeleteExpiredDcLockout::execute($this->Db);
Jobs\DeleteExpiredLogins::execute($this->Db);
Jobs\DeleteExpiredUserRegisterWaitConfirm::execute($this->Container, $this->Db);
Jobs\DeleteFailedLogins::execute($this->Container, $this->Db);
Jobs\DeleteSoftDeleteUsers::execute($this->Container, $this->Db);
Jobs\DeleteOldLogs::execute($this->Container, $this->Db);// @since 1.1.7
// write cache that this job had already run.
$cacheTTL = $this->Cron->getSecondsBeforeNext();
$this->Cron->cacheHadRun($cacheTTL);
unset($cacheTTL);
unset($CronExpression);
return true;
}// endif isDue()
unset($CronExpression);
return false;
}// execute
}