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.
# this is the app's domain name
# 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
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":
bash: ./occ: Permission denied