Added detection of external triggers of the scheduler (#3726)

Added extension to the isCrontabSetup method to detect external triggers of the scheduler, so that in the admin interface the error message is hidden when the scheduler is called by an external trigger.
This commit is contained in:
Raffael Herrmann
2023-10-24 11:25:44 +02:00
committed by GitHub
parent 80ce87e4a9
commit db3e39f0cb

View File

@@ -214,6 +214,9 @@ class Scheduler
// Store states
$this->saveJobStates();
// Store run date
file_put_contents("logs/lastcron.run", (new DateTime("now"))->format("Y-m-d H:i:s"), LOCK_EX);
}
/**
@@ -291,7 +294,7 @@ class Scheduler
}
/**
* Helper to determine if cron job is setup
* Helper to determine if cron-like job is setup
* 0 - Crontab Not found
* 1 - Crontab Found
* 2 - Error
@@ -300,6 +303,13 @@ class Scheduler
*/
public function isCrontabSetup()
{
// Check for external triggers
$last_run = @file_get_contents("logs/lastcron.run");
if (time() - strtotime($last_run) < 120){
return 1;
}
// No external triggers found, so do legacy cron checks
$process = new Process(['crontab', '-l']);
$process->run();