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


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. Nextcloud
  3. Nextcloud Preview Generator / cron trouble

Nextcloud Preview Generator / cron trouble

Scheduled Pinned Locked Moved Solved Nextcloud
nextcloud
9 Posts 6 Posters 2.4k Views 6 Watching
  • 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.
  • necrevistonnezrN Offline
    necrevistonnezrN Offline
    necrevistonnezr
    wrote on last edited by girish
    #1

    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
    0
    • M Offline
      M Offline
      msbt
      App Dev
      wrote on last edited by
      #2

      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

      necrevistonnezrN S 2 Replies Last reply
      1
      • M msbt

        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

        necrevistonnezrN Offline
        necrevistonnezrN Offline
        necrevistonnezr
        wrote on last edited by
        #3

        @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
        1
        • necrevistonnezrN necrevistonnezr

          @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 Offline
          M Offline
          msbt
          App Dev
          wrote on last edited by
          #4

          @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
          0
          • nebulonN Offline
            nebulonN Offline
            nebulon
            Staff
            wrote on last edited by
            #5

            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
            0
            • avatar1024A Offline
              avatar1024A Offline
              avatar1024
              wrote on last edited by
              #6

              2024...and this is still a problem. Is there still no workaround to run a cron job?

              1 Reply Last reply
              1
              • girishG Offline
                girishG Offline
                girish
                Staff
                wrote on last edited by
                #7

                @avatar1024 It's been long solved - https://docs.cloudron.io/apps/#cron .

                I don't have much idea about the app or even why it's exactly needed but I was able to set up a cron like this 0 * * * * echo "==> generating previews" && sudo -u www-data php -f /app/code/occ preview:pre-generate :

                image.png

                avatar1024A 1 Reply Last reply
                1
                • girishG girish

                  @avatar1024 It's been long solved - https://docs.cloudron.io/apps/#cron .

                  I don't have much idea about the app or even why it's exactly needed but I was able to set up a cron like this 0 * * * * echo "==> generating previews" && sudo -u www-data php -f /app/code/occ preview:pre-generate :

                  image.png

                  avatar1024A Offline
                  avatar1024A Offline
                  avatar1024
                  wrote on last edited by
                  #8

                  @girish ooops, thank you Girish, I had somehow missed that it worked with that function.

                  1 Reply Last reply
                  0
                  • M msbt

                    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

                    S Offline
                    S Offline
                    SunDevil
                    wrote on last edited by
                    #9

                    @msbt Thank you immensely! I've been trying to get that to work for ages.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Bookmarks
                    • Search