Cron - seems not to be working

Nextcloud version : 15.0.2
Operating system and version : CentOS 6
Apache or nginx version: Apache 2.4.34
PHP version : 7.2.10

The issue you are facing:

Hello!

Cron was working file (every minute), I have this entry in the crontab, under the correct user:

          • php /home/hoinari/nextcloud/cron.php

But in the admin panel I see that the last cron was ran a few hours ago… This started after I enabled opcache.

The cron log shows that the cron was exectued every minute.

I can copy and run “php /home/hoinari/nextcloud/cron.php” in the console, this leads to Nextcloud seeing that the cron was executed (i get no output)

What could go wrong? How can I see the cron log? (no errors in the Nextcloud panel, under log).

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

Steps to replicate it:

  1. Check the crontab is running
  2. Check last cron run under nextcloud

The output of your Nextcloud log in Admin > Logging:

{"reqId":"XIYhqeHasp3UCxAZ0kX8wwAAAIE","level":2,"time":"2019-03-11T08:51:54+00:00","remoteAddr":"91.206.82.5","user":"--","app":"core","method":"POST","url":"\/index.php\/login?redirect_url=\/index.php\/settings\/admin\/overview","message":"Login failed: 'chip' (Remote IP: '91.206.82.5')","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko\/20100101 Firefox\/65.0","version":"15.0.5.3"}
{"reqId":"XIZE2L0z6s425X7IM-TgPwAAAM8","level":3,"time":"2019-03-11T11:22:01+00:00","remoteAddr":"91.206.82.5","user":"chip","app":"PHP","method":"GET","url":"\/ocs\/v2.php\/apps\/notifications\/api\/v2\/notifications","message":"Module 'mcrypt' already loaded at Unknown#0","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko\/20100101 Firefox\/65.0","version":"15.0.5.3"}
{"reqId":"b0n6jvymh5Y5zREWKZve","level":3,"time":"2019-03-11T11:22:02+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"Module 'mcrypt' already loaded at Unknown#0","userAgent":"--","version":"15.0.5.3"}
{"reqId":"XIZE9r0z6s425X7IM-TgQAAAAMI","level":3,"time":"2019-03-11T11:22:32+00:00","remoteAddr":"91.206.82.5","user":"chip","app":"PHP","method":"GET","url":"\/ocs\/v2.php\/apps\/notifications\/api\/v2\/notifications","message":"Module 'mcrypt' already loaded at Unknown#0","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko\/20100101 Firefox\/65.0","version":"15.0.5.3"}
{"reqId":"XIZFFL0z6s425X7IM-TgQQAAANc","level":3,"time":"2019-03-11T11:23:01+00:00","remoteAddr":"91.206.82.5","user":"chip","app":"PHP","method":"GET","url":"\/ocs\/v2.php\/apps\/notifications\/api\/v2\/notifications","message":"Module 'mcrypt' already loaded at Unknown#0","userAgent":"Mozilla\/5.0 (Windows NT 10.0; Win64; x64; rv:65.0) Gecko\/20100101 Firefox\/65.0","version":"15.0.5.3"}
{"reqId":"zuanV3h3LVVw5dj4Kgwp","level":3,"time":"2019-03-11T11:23:01+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"Module 'mcrypt' already loaded at Unknown#0","userAgent":"--","version":"15.0.5.3"}

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

<?php
$CONFIG = array (
  'instanceid' => 'ocaroi35pb12',
  'passwordsalt' => 'u7ZxiGcAzwa0i83EVMgPGIpTk9E1QJ',
  'secret' => 'iSrBYwgi1rmvio95tOZZn6IBNv8s91lsUZ9yj171vVtk3pMx',
  'trusted_domains' => 
  array (
    0 => 'nextcloud.doihoinari.ro',
  ),
  'datadirectory' => '/home/hoinari/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '15.0.2.0',
  'overwrite.cli.url' => 'https://nextcloud.doihoinari.ro',
  'dbname' => 'xxx',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'xxx',
  'dbpassword' => 'xxx',
  'installed' => true,
);

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

PASTE HERE

The cron command usually needs to run as user “www-data” or however yout web servers user is named. If you try to run the command with your own user, the environment might be different. For testing purposes I would run the command via sudo. Additionally it might be worse to use the full path to the php command (/usr/bin/php) to make sure that the command could be found.

The cron is set to run as my user “hoinari”. I have other crons that run just fine, except this one.

Running the cron manually works! With the ‘hoinari’ user. Crontab logs say the command is executed, but in this case the Nextcloud admin tells that the cron was not run…

As I wrote, the Nextcloud cron job should be run under the web server user, not your own account.
The documentation describes how such a job need to be set-up in detail.

The webserver runs under the ‘hoinari’ user.

Is there any output that the cron.php should have, any log that I can check?

Thanks!

The job normally doesn’t generate any output, but you can check the Nextcloud log file which should contain at least one entry for each execution. Due to the fact that it might take a while to finish all background tasks, you should also limit the job execution to once each 5 or 15 min instead of running it every minute - less often is sometimes better :wink:

it is a fresh install, so i guess for now 1 min is ok…
in the nextcloud log there is nothing related to the cron…

Then you should check why the cron daemon is not running. See http://www.lifelinux.com/how-to-startstoprestart-cron-service-in-linux/ for some hints how to do this.

The cron is running…

I redirected the output from cron.php to a file:

PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib64/php/modules/imagick.so’ - /usr/lib64/php/modules/imagick.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib64/php/modules/memcached.so’ - /usr/lib64/php/modules/memcached.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib64/php/modules/redis.so’ - /usr/lib64/php/modules/redis.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib64/php/modules/uploadprogress.so’ - /usr/lib64/php/modules/uploadprogress.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Parse error: syntax error, unexpected ‘[’ in /home/hoinari/nextcloud/cron.php on line 44
It seems that after I configured opcache, other modules are gone…

Ok, then it should be easy to solve by installing the missing php module.

It should…

I still get the error:

PHP Parse error: syntax error, unexpected ‘[’ in /home/hoinari/nextcloud/cron.php on line 44

At that line there is:

	\OC::$server->getLogger()->debug('Update required, skipping cron', ['app' => 'cron']);

Not sure what happened…

I know what happened, not sure how and how to fix…

I am running PHP 7.2.10.

But… crontab is running PHP5.3.3 (i created a cron to save the output of phpinfo())…

Any ideas how to make the cron take the PHP7? Via CLI it is also using PHP 7.2.10

As I wrote before, you should use the full path to the php binary, because otherwise different search pathes could cause the described problem.

2 Likes

Adding full path (in my case /usr/local/bin/php) solved the issue. Thank you!

1 Like

Can you tell, how you redirected the output?

We got the problem that corn.php seems to do nothing: It returns immediately (without any output/error) and nc webinterface tells us that cron was last run 2 months ago.

Thanks!