Run 'occ files-scan --all' automatically in docker container

Nextcloud version 19.0.1:
Operating system and version (Arch):

I set up Nextcloud on a linux server with docker. Is there any chance to run the command occ files-scan --all with some ā€œchangesā€ inside the web interface (not terminal) e.g. in settings? My docker container donā€™t know anything about commands like ā€˜sudoā€™ or ā€˜crontabā€™, so i want to realize this inside the web interface.

Couldnā€™t find a solution inside web interface. I created a crontab on my host like this:
sudo docker exec -ti --user www-data nextcloud-app /var/www/html/occ files:scan --all

Well, nope, need help anyway.
sudo docker exec -ti --user www-data nextcloud-app /var/www/html/occ files:scan --all is working like a charm. Now i want to use this as crontab:

sudo su
crontab -e

adding this line:
0 12 * * * sudo docker exec -ti --user www-data nextcloud-app /var/www/html/occ files:scan --all
-> run everyday this command at 12:00. But nothing is happening. Why? If i do something simpler like 0 12 * * * echo "test" > test.txt its working perfect - its creating a file ā€˜test.txtā€™. So syntax is correct. Any idea?

Also tried this way:

  1. go inside docker container sudo docker exec -it nextcloud-app /bin/bash
  2. apt install -y cron
  3. apt install -y sudo
  4. sudo crontab -e
  5. add 0 12 * * * sudo -u www-data /var/www/html/occ files:scan --all
    This is not working. So a cron inside a docker container also dont work. Tried the echo example above inside container, but this also dont work.

root@287338265e0d:/var/www/html# /etc/init.d/cron status [FAIL] cron is not running ... failed!

Edit: So stupid, i had to activate this:
/etc/init.d/cron start

Now the cron is running inside the docker container and the occ commands runs well.

which image?

on my system:

docker exec -u www-data nextcloud-app php occ files:scan --all

works.

1 Like

thanks
it work for me.