linuxserver / docker-nextcloud

GNU General Public License v3.0
677 stars 128 forks source link

[BUG] crond runs twice #334

Closed janusn closed 11 months ago

janusn commented 11 months ago

Is there an existing issue for this?

Current Behavior

A task declared in /config/crontabs/abc is called twice.

$ sudo docker exec -it nextcloud /bin/bash
# ps aux | grep crond
root         406  0.0  0.0   1596   768 ?        Ss   01:37   0:00 /usr/sbin/crond -f -S -l 5
root         407  0.0  0.0   1596   768 ?        Ss   01:37   0:00 /usr/sbin/crond -f -S -l 5
root         477  0.0  0.0   1588   640 pts/0    S+   01:41   0:00 grep crond

Expected Behavior

A line in /config/crontabs/abc should be called once.

Steps To Reproduce

Suppose the container is named as 'nextcloud' and created by docker compose with ./config mapped to /config inside the container.

  1. $ sudo docker exec -it nextcloud /bin/bash
  2. # echo '* * * * * /bin/echo `whoami` >> /config/debug-crond.log ; /bin/echo `date` >> /config/debug-crond.log' >> /config/crontabs/abc
  3. # exit
  4. $ sudo docker compose restart
  5. wait for a couple minutes
  6. $ cat ./config/debug-crond.log
  7. The output looks like:
    abc
    abc
    2023.07.16-00.00.00
    2023.07.16-00.00.00
    abc
    abc
    2023.07.16-00.01.00
    2023.07.16-00.01.00

Environment

- OS: Ubuntu 23.04 64bit / Linux 6.2.0-24-generic
- How docker service was installed: sudo apt install docker
- nextcloud image tag: 27.0.0-ls255

CPU architecture

x86-64

Docker creation

$ sudo docker compose up -d

the content of compose.yaml:

---
version: "2.1"
services:
  nextcloud:
    image: "linuxserver/nextcloud:latest"
    container_name: nextcloud
    cap_add:
      - CAP_SYS_NICE
    environment:
      - PUID=1016
      - PGID=1016
      - TZ=Europe/London
      - DOCKER_MODS=linuxserver/mods:universal-cron
    ports:
      - "7443:443"
    volumes:
      - "./config:/config:rw"
      - "./data:/data:rw"
    restart: unless-stopped
networks:
  default:
    name: nextcloud_default
    external: true

Container logs

[mod-init] Attempting to run Docker Modification Logic
[mod-init] Adding linuxserver/mods:universal-cron to container
[mod-init] Downloading linuxserver/mods:universal-cron from lscr.io
[mod-init] Installing linuxserver/mods:universal-cron
[mod-init] linuxserver/mods:universal-cron applied to container
[migrations] started
[migrations] 01-nginx-site-confs-default: skipped
[migrations] 02-default-location: skipped
[migrations] done
───────────────────────────────────────

      ██╗     ███████╗██╗ ██████╗ 
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝ 

   Brought to you by linuxserver.io
───────────────────────────────────────

To support LSIO projects visit:
https://www.linuxserver.io/donate/

───────────────────────────────────────
GID/UID
───────────────────────────────────────

User UID:    1016
User GID:    1016
───────────────────────────────────────

using keys found in /config/keys
Initializing nextcloud 27.0.0.8 (this can take a while) ...
Setting permissions
Initializing finished
**** The following active confs have different version dates than the samples that are shipped. ****
**** This may be due to user customization or an update to the samples. ****
**** You should compare the following files to the samples in the same folder and update them. ****
**** Use the link at the top of the file to view the changelog. ****
┌────────────┬────────────┬────────────────────────────────────────────────────────────────────────┐
│  old date  │  new date  │ path                                                                   │
├────────────┼────────────┼────────────────────────────────────────────────────────────────────────┤
│ 2022-08-16 │ 2023-04-13 │ /config/nginx/nginx.conf                                               │
│ 2022-08-20 │ 2023-06-24 │ /config/nginx/ssl.conf                                                 │
│ 2022-08-20 │ 2023-06-23 │ /config/nginx/site-confs/default.conf                                  │
└────────────┴────────────┴────────────────────────────────────────────────────────────────────────┘
**** The following site-confs have extensions other than .conf ****
**** This may be due to user customization. ****
**** You should review the files and rename them to use the .conf extension or remove them. ****
**** nginx.conf will only include site-confs with the .conf extension. ****
/config/nginx/site-confs/default.conf.2023-05-13
**** cron package already installed, skipping ****
[custom-init] No custom files found, skipping...
[ls.io-init] done.
github-actions[bot] commented 11 months ago

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

nemchik commented 11 months ago

You should not need to use the universal cron mod on this container. cron is included and running by default. I will look into adjusting the mod to skip running cron if the container already runs it.

janusn commented 11 months ago

You should not need to use the universal cron mod on this container. cron is included and running by default. I will look into adjusting the mod to skip running cron if the container already runs it.

Thanks for looking into it.

Actually, I have encountered this issue when I modified the host file of /docker/nextcloud/config/crontabs/abc and the volumes maps "/docker/nextcloud/config:/config:rw" inside the container. I did not change any cron settings otherwise.

nemchik commented 11 months ago

I just looked a little closer and see that we don't have an out of the box way to run cron as abc without the mod or having the root cron use s6-setuidgid abc.

This is a bit more motivation for making adjustments to the cron mod. I'll have to think through exactly how to handle it though.