File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 149149 }
150150
151151 $ logger ->debug ('CLI cron call has selected job with ID ' . strval ($ job ->getId ()), ['app ' => 'cron ' ]);
152+ $ timeBefore = time ();
152153 $ job ->execute ($ jobList , $ logger );
154+ $ timeAfter = time ();
155+ $ cronInterval = 5 * 60 ;
156+ $ timeSpent = $ timeAfter - $ timeBefore ;
157+ if ($ timeSpent > $ cronInterval ) {
158+ $ logLevel = match (true ) {
159+ $ timeSpent > $ cronInterval * 128 => \OCP \ILogger::FATAL ,
160+ $ timeSpent > $ cronInterval * 64 => \OCP \ILogger::ERROR ,
161+ $ timeSpent > $ cronInterval * 16 => \OCP \ILogger::WARN ,
162+ $ timeSpent > $ cronInterval * 8 => \OCP \ILogger::INFO ,
163+ default => \OCP \ILogger::DEBUG ,
164+ };
165+ $ logger ->log (
166+ $ logLevel ,
167+ 'Background job ' . $ jobDetails . ' ran for ' . $ timeSpent . ' seconds ' ,
168+ ['app ' => 'cron ' ]
169+ );
170+ }
171+
153172
154173 // clean up after unclean jobs
155174 \OC_Util::tearDownFS ();
159178 $ executedJobs [$ job ->getId ()] = true ;
160179 unset($ job );
161180
162- if (time () > $ endTime ) {
181+ if ($ timeAfter > $ endTime ) {
163182 break ;
164183 }
165184 }
You can’t perform that action at this time.
0 commit comments