Nextcloud on Synology DiskStation

Nextcloud and Synology: Cron stops executing

Since the release of Nextcloud 21.0.0, there have been increasing reports that cron and occ commands can no longer be executed. For once, these issues were not limited to Synology DiskStations or DSM. Since release 21.0.2, the error has disappeared for some users, but it persists for others. With 21.0.3 there were some changes that were actually intended for Nextcloud 22, but were quietly and secretly made for 21 as well.

The issue

If you let the server’s cron – in the case of the DisksStation this is the task scheduler – execute Nextclouds cron, it will no longer be executed. You get no error messages (at least from 21.0.3) calling cron.php works, but it doesn’t do what it’s supposed to do. Some users have already found that the cron works again if you remove the memcache.local line from the Nextcloud config.

The reason

By default, PHP caching (APCu) is disabled on the command line. If you’ve read my articles, you might remember that we enabled PHP caching in the PHP profile for Nextcloud. Since the missing caching causes problems with Nextcloud’s cron in some cases, it was decided simply not to run the cron if APCu is deactivated. If you look at the Nextcloud documentation, it suddenly says:

“APCu is disabled by default on CLI which could cause issues with nextcloud’s cron jobs. Please make sure you set the apc.enable_cli to 1 on your php.ini config file or append --define apc.enable_cli=1 to the cron job call.”

The solution

For Synology DiskStations, the question now arises again, where is the right place for the changes. The variable apc.enable_cli is found in the PHP profile. But setting it to 1 doesn’t solve the problem. The PHP profile only applies to the web server, and APCu works there. But we want APCu on the command line.

To fix the problem, create the file /usr/local/etc/phpXX/cli/conf.d/user_settings.ini using e.g. PuTTY and add the following content there:

extension = apcu.so

[apc]
apc.shm_size = 512M
apc.enable_cli = 1

Save and close the file. Now you have to set the correct permissions, otherwise it won’t work:

chmod -R 644 /usr/local/etc/phpXX/cli/conf.d/user_settings.ini

Many thanks to everyone from the German Synology Forum who have also been looking for a solution and especially to those who have put things together.

4 thoughts on “Nextcloud and Synology: Cron stops executing

  1. Hi,
    Since upgrading to DSM7 the cron is not working. I am using
    DSM 7.1-42661 Update 1
    which comes with PHP80
    I followed all your steps but cron still reports that there is no memchache and stops.
    Any ideas?
    thanks

    1. Hi,

      Things changed again, I updated the post, please set the permissions as described.

      Regards,
      Andreas

  2. Sounds great. Too bad I have absolutely no idea how to “create a file using PuTTY”.
    I can log into PuTTY alright. But you are talking to a Synology-only lowlife here who has no idea about command lines. I guess I have to type something like “create file blabla” but I have no idea.

    1. Hi Alex,

      This has nothing to do with Synology per se. As soon as you connect to your NAS via PuTTY you are on the linux command line.
      There you can use almost all common UNIX commands.
      For editing text files, the Editor vi is installed.
      You Create/Open a file with the command “vi /path/to/file”.
      The handling of vi is a bit confusing if you are not used to it. I would recommend reading an online tutorial on how to work with vi.

      Regards,
      Andreas

Leave a Reply

Your email address will not be published. Required fields are marked *