Skip to content

Commit

Permalink
Always log cron execution
Browse files Browse the repository at this point in the history
There was a setting to disable the last execution of cron. There is no known
problem with this write access and it was also questioned when this feature
was build in owncloud/core#7689 (comment)

Recently there was also a bug report about a non-visible last cron execution
(#6088) - let's better remove this.

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
  • Loading branch information
MorrisJobke committed Aug 17, 2017
1 parent f0eb882 commit 1c38a83
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 40 deletions.
7 changes: 0 additions & 7 deletions config/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -738,13 +738,6 @@
*/
'log_query' => false,

/**
* Log successful cron runs.
*
* Defaults to ``true``
*/
'cron_log' => true,

/**
* Enables log rotation and limits the total size of logfiles. The default is 0,
* or no rotation. Specify a size in bytes, for example 104857600 (100 megabytes
Expand Down
4 changes: 1 addition & 3 deletions cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,7 @@
}

// Log the successful cron execution
if (\OC::$server->getConfig()->getSystemValue('cron_log', true)) {
\OC::$server->getConfig()->setAppValue('core', 'lastcron', time());
}
\OC::$server->getConfig()->setAppValue('core', 'lastcron', time());
exit();

} catch (Exception $ex) {
Expand Down
1 change: 0 additions & 1 deletion lib/private/Settings/Admin/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ public function getForm() {

// Background jobs
'backgroundjobs_mode' => $this->config->getAppValue('core', 'backgroundjobs_mode', 'ajax'),
'cron_log' => $this->config->getSystemValue('cron_log', true),
'lastcron' => $this->config->getAppValue('core', 'lastcron', false),
'cronErrors' => $this->config->getAppValue('core', 'cronErrors'),
'cli_based_cron_possible' => function_exists('posix_getpwuid'),
Expand Down
40 changes: 19 additions & 21 deletions settings/templates/settings/admin/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,28 +156,26 @@

<div class="section" id="backgroundjobs">
<h2 class="inlineblock"><?php p($l->t('Background jobs'));?></h2>
<?php if ($_['cron_log']): ?>
<p class="cronlog inlineblock">
<?php if ($_['lastcron'] !== false):
$relative_time = relative_modified_date($_['lastcron']);
$absolute_time = OC_Util::formatDate($_['lastcron']);
if (time() - $_['lastcron'] <= 3600): ?>
<span class="status success"></span>
<span class="crondate" title="<?php p($absolute_time);?>">
<?php p($l->t("Last job ran %s.", [$relative_time]));?>
</span>
<?php else: ?>
<span class="status error"></span>
<span class="crondate" title="<?php p($absolute_time);?>">
<?php p($l->t("Last job execution ran %s. Something seems wrong.", [$relative_time]));?>
</span>
<?php endif;
else: ?>
<p class="cronlog inlineblock">
<?php if ($_['lastcron'] !== false):
$relative_time = relative_modified_date($_['lastcron']);
$absolute_time = OC_Util::formatDate($_['lastcron']);
if (time() - $_['lastcron'] <= 3600): ?>
<span class="status success"></span>
<span class="crondate" title="<?php p($absolute_time);?>">
<?php p($l->t("Last job ran %s.", [$relative_time]));?>
</span>
<?php else: ?>
<span class="status error"></span>
<?php p($l->t("Background job didn’t run yet!"));
endif; ?>
</p>
<?php endif; ?>
<span class="crondate" title="<?php p($absolute_time);?>">
<?php p($l->t("Last job execution ran %s. Something seems wrong.", [$relative_time]));?>
</span>
<?php endif;
else: ?>
<span class="status error"></span>
<?php p($l->t("Background job didn’t run yet!"));
endif; ?>
</p>
<a target="_blank" rel="noreferrer" class="icon-info"
title="<?php p($l->t('Open documentation'));?>"
href="<?php p(link_to_docs('admin-background-jobs')); ?>"></a>
Expand Down
10 changes: 2 additions & 8 deletions tests/lib/Settings/Admin/ServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@ public function testGetForm() {
->with('core', 'backgroundjobs_mode', 'ajax')
->willReturn('ajax');
$this->config
->expects($this->at(4))
->expects($this->at(3))
->method('getAppValue')
->with('core', 'lastcron', false)
->willReturn(false);
$this->config
->expects($this->at(5))
->expects($this->at(4))
->method('getAppValue')
->with('core', 'cronErrors')
->willReturn('');
Expand All @@ -94,11 +94,6 @@ public function testGetForm() {
->method('getSystemValue')
->with('check_for_working_wellknown_setup', true)
->willReturn(true);
$this->config
->expects($this->at(3))
->method('getSystemValue')
->with('cron_log', true)
->willReturn(true);
$this->l10n
->expects($this->at(0))
->method('t')
Expand Down Expand Up @@ -139,7 +134,6 @@ public function testGetForm() {

// Background jobs
'backgroundjobs_mode' => 'ajax',
'cron_log' => true,
'lastcron' => false,
'cronErrors' => '',
'cli_based_cron_possible' => true,
Expand Down

0 comments on commit 1c38a83

Please sign in to comment.