Cronjob not executing

Nextcloud version : 18.0.0.10
Operating system and version: Ubuntu Server 18.04 LTS
Apache or nginx version : 2.4.29
PHP version : 7.2.24

The issue you are facing:
My nextcloud is complaining about cron.php not beeing executed.

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

Steps to replicate it:

  1. None,

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 (
  'passwordsalt' => '***',
  'secret' => '****',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => '192.168.0.10',
    2 => 'cloud.***.net',
    3 => 'cloud.***.net',
  ),
  'datadirectory' => '/mnt/ncdata',
  'dbtype' => 'pgsql',
  'version' => '18.0.0.10',
  'overwrite.cli.url' => 'https://cloud.quirinlippl.net/',
  'dbname' => 'nextcloud_db',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'ncadmin',
  'dbpassword' => '****',
  'installed' => true,
  'instanceid' => 'ocns94zifdu4',
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'loglevel' => '2',
  'mail_smtpmode' => 'smtp',
  'remember_login_cookie_lifetime' => '1800',
  'log_rotate_size' => '10485760',
  'trashbin_retention_obligation' => 'auto, 180',
  'versions_retention_obligation' => 'auto, 365',
  'simpleSignUpLink.shown' => 'false',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'filelocking.enabled' => true,
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0.5,
    'dbindex' => 0,
    'password' => '***',
  ),
  'logtimezone' => 'Europe/Berlin',
  'htaccess.RewriteBase' => '/',
  'enable_previews' => true,
  'preview_libreoffice_path' => '/usr/bin/libreoffice',
  'maintenance' => false,
  'mail_smtpsecure' => 'tls',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => '***',
  'mail_domain' => '***.com',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'SMTP.office365.com',
  'mail_smtpport' => '587',
  'mail_smtpname' => '***@***.com',
  'mail_smtppassword' => '****',
  'app_install_overwrite' =>
  array (
    0 => 'ocr',
    1 => 'dropit',
  ),
);

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

[Thu Feb 06 06:25:01.525468 2020] [mpm_event:notice] [pid 16070:tid 140586132143040] AH00489: Apache/2.4.29 (Ubuntu) OpenSSL/1.1.1 configured -- resuming normal operations
[Thu Feb 06 06:25:01.527570 2020] [core:notice] [pid 16070:tid 140586132143040] AH00094: Command line: '/usr/sbin/apache2'


Hi Guys,

i recently noticed my cron.php was not executed since 6 days now. I’m wondering what is causing this?
When I look into /var/mail/www-data I can see my cron tasks I added into

crontab  -u www-data -e

are beeing executed.

My crontab:

*/5 * * * * php -f /var/www/nextcloud/cron.php
*/15 * * * * /var/www/nextcloud/occ preview:pre-generate >> /var/log/previewgenerator.log
30 2 1 * * /var/www/nextcloud/occ trashbin:cleanup
0 */1 * * * /var/www/nextcloud/occ maps:scan-photos
*/10 * * * * /var/www/nextcloud/occ files:cleanup

Has anyone a clue?

My root crontab is:

#*/5 * * * * php -f /var/www/nextcloud/cron.php > /dev/null 2>&1
0 2 * * 1 /var/scripts/update.sh minor >> /var/log/nextcloud/update.log
3 */12 * * * /var/scripts/letsencryptrenew.sh
@weekly /var/scripts/dockerprune.sh

I installed nextcloud via the VM Script.

quintz

Add absolute path to your php binay e. g. “/usr/bin/php”

And check your system log files.

1 Like

That didn’t do the trick, as it seems … :-/

Feb  6 13:05:00 cloud crontab[12825]: (root) BEGIN EDIT (www-data)
Feb  6 13:05:01 cloud CRON[12841]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb  6 13:05:01 cloud CRON[12842]: (www-data) CMD (php -f /var/www/nextcloud/cron.php)
Feb  6 13:05:08 cloud crontab[12825]: (root) REPLACE (www-data)
Feb  6 13:05:08 cloud crontab[12825]: (root) END EDIT (www-data)
Feb  6 13:06:01 cloud cron[872]: (www-data) RELOAD (crontabs/www-data)
Feb  6 13:06:38 cloud postfix/pickup[4761]: 6D401160124: uid=33 from=<www-data>
Feb  6 13:06:38 cloud postfix/cleanup[12962]: 6D401160124: message-id=<20200206120638.6D401160124@nextcloud.fritz.box>
Feb  6 13:06:38 cloud postfix/qmgr[1523]: 6D401160124: from=<www-data@******.net>, size=6894887, nrcpt=1 (queue active)
Feb  6 13:06:39 cloud postfix/local[12964]: 6D401160124: to=<www-data@******.net>, orig_to=<www-data>, relay=local, delay=1.1, delays=0.77/0/0/0.28, dsn=2.0.0, status=sent (delivered to mailbox)
Feb  6 13:06:39 cloud postfix/qmgr[1523]: 6D401160124: removed
Feb  6 13:09:01 cloud CRON[13219]: (root) CMD (  [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi)
Feb  6 13:09:07 cloud systemd[1]: Starting Clean php session files...
Feb  6 13:09:08 cloud systemd[1]: Started Clean php session files.
Feb  6 13:10:01 cloud CRON[13347]: (www-data) CMD (/usr/bin/php -f /var/www/nextcloud/cron.php)
Feb  6 13:10:01 cloud CRON[13348]: (www-data) CMD (/var/www/nextcloud/occ files:cleanup)
Feb  6 13:10:01 cloud postfix/pickup[4761]: CA2D7160124: uid=33 from=<www-data>
Feb  6 13:10:01 cloud postfix/cleanup[13363]: CA2D7160124: message-id=<20200206121001.CA2D7160124@nextcloud.fritz.box>
Feb  6 13:10:01 cloud postfix/qmgr[1523]: CA2D7160124: from=<www-data@******.net>, size=622, nrcpt=1 (queue active)
Feb  6 13:10:01 cloud postfix/local[13365]: CA2D7160124: to=<www-data@******.net>, orig_to=<www-data>, relay=local, delay=0.05, delays=0.03/0/0/0.01, dsn=2.0.0, status=sent (delivered to mailbox)
Feb  6 13:10:01 cloud postfix/qmgr[1523]: CA2D7160124: removed
Feb  6 13:15:01 cloud CRON[13700]: (www-data) CMD (/var/www/nextcloud/occ preview:pre-generate >> /var/log/previewgenerator.log)
Feb  6 13:15:01 cloud CRON[13699]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb  6 13:15:01 cloud CRON[13702]: (www-data) CMD (/usr/bin/php -f /var/www/nextcloud/cron.php)
Feb  6 13:17:01 cloud CRON[13909]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Feb  6 13:20:01 cloud CRON[14279]: (www-data) CMD (/usr/bin/php -f /var/www/nextcloud/cron.php)
Feb  6 13:20:01 cloud CRON[14278]: (www-data) CMD (/var/www/nextcloud/occ files:cleanup)
Feb  6 13:20:01 cloud postfix/pickup[4761]: A3ED4160124: uid=33 from=<www-data>
Feb  6 13:20:01 cloud postfix/cleanup[14296]: A3ED4160124: message-id=<20200206122001.A3ED4160124@nextcloud.fritz.box>
Feb  6 13:20:01 cloud postfix/qmgr[1523]: A3ED4160124: from=<www-data@******.net>, size=622, nrcpt=1 (queue active)
Feb  6 13:20:01 cloud postfix/local[14298]: A3ED4160124: to=<www-data@******.net>, orig_to=<www-data>, relay=local, delay=0.04, delays=0.03/0/0/0.01, dsn=2.0.0, status=sent (delivered to mailbox)
Feb  6 13:20:01 cloud postfix/qmgr[1523]: A3ED4160124: removed
Feb  6 13:25:01 cloud CRON[14825]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Feb  6 13:25:01 cloud CRON[14826]: (www-data) CMD (/usr/bin/php -f /var/www/nextcloud/cron.php)

For some reason it now works again - can’t tell why. :upside_down_face:

Thanks! Maybe this helps others:

My cron.php wasn’t executed for about two years (which you can see in the web interface: https://my-nextcloud-instance.com/settings/admin/serverinfo ) and I had some issues with locked files:

  • Client Error 'Server replied “423 Locked” to “DELETE …” ’ / ‘Server hat “423 Locked” auf “DELETE …” geantwortet…’
  • “oc_file_locks” table in the sql database was extremely large.

Unfortunately, I’m not sure which of the three or if all were the reason, but the combination these solutions helped in my case:

  • your hint: specifying the exact path for php, in my case (depending on the version Nextcloud uses, which can be seen on your web interface: https://my-nextcloud-instance.com/settings/admin/serverinfo):
    */5 * * * * /usr/bin/php7.3 -f /var/www/path_to_nextcloud/cron.php
  • the hint here: adding execution rights for the cron.php file for the www user:
    sudo -u www-data chmod u+x /var/www/path_to_nextcloud/cron.php
    … which is now “-rwxr–r--” = 744 in my case
    EDIT: ok, apparently this point doesn’t make sense, see comment below - sorry! :stuck_out_tongue:
  • I also ran
    sudo -u www-data php occ files:scan --all
    once (in the nextcloud directory /var/www/path_to_nextcloud/ ).

The web interface now showed that the script ran one year ago the last time (so not 2 anymore).
Not sure, but I had the impression that the cron.php had to run multiple times to step by step reduce the time displayed in the web interface (7 months, then 4, … finally “just now”)? (So manually running the cron.php a couple of times might speed this up?)

Why doing that? php files are not executable. They are called by the php binary. Not every topic in the forum is a valid comment.