Cron-Job execution

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version :18.0.3
Operating system and version: Ubuntu 18.04.4 LTS (GNU/Linux 4.15.0-54-generic x86_64)
Apache or nginx version : Apache/2.4.29 (Ubuntu)
PHP version:PHP 7.3.16-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Mar 20 2020 13:51:46) ( NTS )

The issue you are facing:
I get some “Security- & Installation” Warnings. One of them is the following:

Letzte Cron-Job-Ausführung: Vor 8 Monaten. Möglicherweise liegt ein Fehler vor. [Überprüfen Sie die Cron-Job Einstellungen]

I followed the manual and this is what i get:

root@32967:/# crontab -u www-data -l

# Edit this file to introduce tasks to be run by cron.

#

# Each task to run has to be defined through a single line

# indicating with different fields when the task will be run

# and what command to run for the task

#

# To define the time you can provide concrete values for

# minute (m), hour (h), day of month (dom), month (mon),

# and day of week (dow) or use '’ in these fields (for ‘any’).#*

# Notice that tasks will be started based on the cron’s system

# daemon’s notion of time and timezones.

#

# Output of the crontab jobs (including errors) is sent through

# email to the user the crontab file belongs to (unless redirected).

#

# For example, you can run a backup of all your user accounts

# at 5 a.m every week with:

# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/

#

# For more information see the manual pages of crontab(5) and cron(8)

#

# m h dom mon dow command

*/5 * * * * php -f /var/www/nextcloud/cron.php

But the message still appears. How can i solve this issue using ssh ?

Is this the first time you’ve seen this error? No

Steps to replicate it:

  1. Log in as admin
  2. Go to settings
  3. got to overview

The output of your Nextcloud log in Admin > Logging:

PASTE HERE

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'ocu4cd7liilp',
  'passwordsalt' => '',
  'secret' => '',
  'trusted_domains' => 
  array (
    0 => '',
    1 => '',
  ),
  'datadirectory' => '/home/data/',
  'dbtype' => 'mysql',
  'version' => '18.0.3.0',
  'overwrite.cli.url' => '',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextclouduser',
  'dbpassword' => '',
  'installed' => true,
  'mysql.utf8mb4' => true,
  'maintenance' => false,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => '',
  'mail_domain' => '',
  'mail_smtphost' => '149.hosttech.eu',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpport' => '587',
  'mail_smtpauth' => 1,
  'mail_smtpname' => '',
  'mail_smtppassword' => '',
  'skeletondirectory' => '',
  'updater.secret' => '$2y$10$aiU6jNZISRYAASwtAdZz5OYaCHuND9FYQ18qg8diIUkZzH9k5qi8C',
  'theme' => '',
  'loglevel' => 2,
);

The output of your Apache/nginx/system log in /var/log/____:


Apr  4 20:05:20 32967 systemd[20339]: Listening on GnuPG cryptographic agent and passphrase cache.
Apr  4 20:05:20 32967 systemd[20339]: Reached target Paths.
Apr  4 20:05:20 32967 systemd[20339]: Reached target Sockets.
Apr  4 20:05:20 32967 systemd[20339]: Reached target Basic System.
Apr  4 20:05:20 32967 systemd[20339]: Reached target Default.
Apr  4 20:05:20 32967 systemd[20339]: Startup finished in 23ms.
Apr  4 20:05:20 32967 systemd[1]: Started User Manager for UID 0.
Apr  4 20:09:01 32967 CRON[20629]: (root) CMD (  [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi)
Apr  4 20:09:17 32967 crontab[20649]: (root) BEGIN EDIT (www-data)
Apr  4 20:09:17 32967 systemd[1]: Starting Clean php session files...
Apr  4 20:09:17 32967 systemd[1]: Started Clean php session files.
Apr  4 20:09:25 32967 crontab[20649]: (root) END EDIT (www-data)
Apr  4 20:09:41 32967 crontab[20777]: (root) BEGIN EDIT (www-data)
Apr  4 20:10:01 32967 crontab[20777]: (root) END EDIT (www-data)
Apr  4 20:10:01 32967 CRON[20815]: (www-data) CMD (php -f /var/www/nextcloud/cron.php)
Apr  4 20:15:01 32967 CRON[21272]: (www-data) CMD (php -f /var/www/nextcloud/cron.php)
Apr  4 20:15:01 32967 CRON[21274]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Apr  4 20:17:01 32967 CRON[21441]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Apr  4 20:20:01 32967 CRON[21594]: (www-data) CMD (php -f /var/www/nextcloud/cron.php)
Apr  4 20:25:01 32967 CRON[21993]: (www-data) CMD (php -f /var/www/nextcloud/cron.php)
Apr  4 20:25:01 32967 CRON[21994]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Apr  4 20:30:01 32967 CRON[22347]: (www-data) CMD (php -f /var/www/nextcloud/cron.php)
Apr  4 20:35:01 32967 CRON[22745]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Apr  4 20:35:01 32967 CRON[22746]: (www-data) CMD (php -f /var/www/nextcloud/cron.php)

Thank you for your support

Hi, could you please check, if your command contains a newline? The cron command manual shows:

cron requires that each entry in a crontab end in a newline character. If the last entry in a crontab is missing the newline, cron will consider the crontab (at least partially) broken and refuse to install it.

So add at least one “return” at the end of your crontab table and check the nextcloud messages again after 10 minutes. Within that time the php command should be executed.

Edit: Well, on the other side your syslog shows that the cron.php was executed. But give it a try.

Could you please execute the follow command on shell? This is to check the permissions of the cron.php file.

ls -l /var/www/nextcloud/cron.php

I encountered a similar problem: Currently I have NC 21.0.3. Some weeks ago I encountered an error with cron.
At that time (May 12) I got an error message that something is wrong with cron (nfortunately I don’t remember if I chose Ajax, Webcron or cron).

Today I decided to switch to “cron”, checked that ./nextcloud/cron.php has execution permissions and ran a check. Though I use logrotate for all log files, the error message is still there.

In a next step I deleted all records in the nextcloud.log file which resides in NC’s data directory. The message error message referring to a misconfiguration of the cron system is still there.

Could you tell me where NC stores such error message, please? Note: By my deployment of logrotate, NC log files (older than today) are no longer accessible by NC. And deleting records in nextcloud.log (as described above), this file cannot also not be a source for NC to tell me that on May12 an error occurred.

Best regards
Dieter

Since NC 22 I have suddenly the same problem. With the previous Version the cron job was running fine. Now i get the error message, that cron job is not running.

But when looking at the command sudo systemctl status cron via ssh, i see, that the cron job is running fine.
Could it be a bug?

br
Tobias

Likely it’s getting tripped up by an outdated app. For me the maps app makes cron fail.