diff --git a/cron.php b/cron.php index 65f59cd47317..d86d3df986a7 100644 --- a/cron.php +++ b/cron.php @@ -118,11 +118,9 @@ break; } - $logger->debug('Run ' . get_class($job) . ' job with ID ' . $job->getId(), ['app' => 'cron']); $job->execute($jobList, $logger); // clean up after unclean jobs \OC_Util::tearDownFS(); - $logger->debug('Finished ' . get_class($job) . ' job with ID ' . $job->getId(), ['app' => 'cron']); $jobList->setLastJob($job); $executedJobs[$job->getId()] = true; diff --git a/lib/private/BackgroundJob/Job.php b/lib/private/BackgroundJob/Job.php index e72688948484..6d385addbdde 100644 --- a/lib/private/BackgroundJob/Job.php +++ b/lib/private/BackgroundJob/Job.php @@ -49,7 +49,18 @@ abstract class Job implements IJob { public function execute($jobList, ILogger $logger = null) { $jobList->setLastRun($this); try { + //storing job start time + $jobStartTime = time(); + + \OCP\Util::writeLog('cron', 'Started background job of class : ' . get_class($this) . ' with arguments : ' . print_r($this->argument, true), \OCP\Util::DEBUG); + $this->run($this->argument); + + //storing job end time + $jobEndTime = time(); + $timeTaken = $jobEndTime - $jobStartTime; + + \OCP\Util::writeLog('cron', "Finished background job, the job took : $timeTaken seconds, " . "this job is an instance of class : " . get_class($this) . 'with arguments : ' . print_r($this->argument, true), \OCP\Util::DEBUG); } catch (\Exception $e) { if ($logger) { $logger->logException($e, [