Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


    Cloudron Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular

    Solved Nextcloud Preview Generator / cron trouble

    Nextcloud
    nextcloud
    3
    5
    930
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • necrevistonnezr
      necrevistonnezr last edited by girish

      I try to use the Nextcloud preview generator: https://apps.nextcloud.com/apps/previewgenerator which relies on the Nextcloud "occ" command and cron.

      First of all, I can't get cron to work. I tried to use the following script by @girish as quoted in How to add cronjob to running cloudron app?:

      As others said, usually the cron job is part of the app itself. If for some reason you want to run some cron task outside the scope of the app, then you can use a script like below and put it in the crontab of your server.

      #!/bin/bash
      
      # this is the app's domain name
      app="test.smartserver.space"
      
      # detect the container id of the app
      container_id=$(docker ps -q -f label=fqdn=$app -f label=isSubcontainer=false)
      echo "App container id is : $container_id"
      
      # we can now run arbitrary commands in the container. below we run a command as the www-data user.
      docker exec $container_id sudo -u www-data ls -l
      

      This script produces the following errors if I try to run a command on my Nextcloud instance at
      "cloud.domain.tld"

      Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.39/containers/json?filters=%7B%22label%22%3A%7B%22fqdn%3Dcloud.domain.tld%22%3Atrue%2C%22isSubcontainer%3Dfalse%22%3Atrue%7D%7D: dial unix /var/run/docker.sock: connect: permission denied
      App container id is :
      Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.39/containers/sudo/json: dial unix /var/run/docker.sock: connect: permission denied
      

      Second, the "occ" command on Nextcloud is not usable currently. If I try to run occ on the webterminal of Nextcloud, I only get a "permision denied":

      root@e8e62423-6b94-4329-8b43-sdf82345f4aa8:/app/code# ./occ
      bash: ./occ: Permission denied
      
      1 Reply Last reply Reply Quote 0
      • M
        msbt App Dev last edited by

        To run the occ tool in nextcloud, you need to use sudo -u www-data php -f /app/code/occ ... as suggested here.

        As for the cron itself: I think it should run every 5 minutes by default

        necrevistonnezr 1 Reply Last reply Reply Quote 0
        • necrevistonnezr
          necrevistonnezr @msbt last edited by

          @msbt said in Nextcloud Preview Generator / cron trouble:

          To run the occ tool in nextcloud, you need to use sudo -u www-data php -f /app/code/occ ... as suggested here.

          thanks, the following command worked in webterminal to create previews:

          sudo -u www-data php -f /app/code/occ preview:generate-all -vvv
          

          @msbt said in Nextcloud Preview Generator / cron trouble:

          As for the cron itself: I think it should run every 5 minutes by default

          I still don't understand how and where to add this command which should be run by cron - I can see that the Nextcloud web terminal has a "Scheduler/cron" tab, but how do I add a command?

          Nextcloud said in Nextcloud Preview Generator:

          Important: To enable pre-generation of previews you must add php /var/www/nextcloud/occ preview:pre-generate to a system cron job that runs at times of your choosing.

          M 1 Reply Last reply Reply Quote 0
          • M
            msbt App Dev @necrevistonnezr last edited by

            @necrevistonnezr said in Nextcloud Preview Generator / cron trouble:

            I still don't understand how and where to add this command which should be run by cron - I can see that the Nextcloud web terminal has a "Scheduler/cron" tab, but how do I add a command?

            In should-land this wouldn't be necessary, because the application uses the internal cron.php to run the cronjobs. There's an open issue on github which asks the same thing and wouldn't require you to fiddle around with custom cronjobs, but apparently it's not a big enough issue for the developer to fix this. Not sure if there's another way to trigger a cronjob without making a custom image and adding it to the crontab.

            1 Reply Last reply Reply Quote 0
            • nebulon
              nebulon Staff last edited by

              As @msbt mentions, the proper solution is to have the preview generator fixed, not to create band-aids for that on the platform level. @necrevistonnezr maybe you can comment on that github issue to raise awareness, afterall it is basically just a missing feature of the application, not Cloudron as such.

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Powered by NodeBB