Cronjob not executing

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?)