Skip to content

Every restart of Docker container adds a new cron entry in /var/spool/cron/crontabs/root #486

Description

@codeproducer198

Problem

I restart my Seafile Docker CE v13 version every night. With every restart of the container the /scripts/enterpoint.sh executes the lines

# logrotate
cat /scripts/logrotate-conf/logrotate-cron >> /var/spool/cron/crontabs/root
/usr/bin/crontab /var/spool/cron/crontabs/root

and therefore the /var/spool/cron/crontabs/root grows daily with the same entries, logrotate tries to rotate daily multipe times in parallel and results in logrotate errors.

I decided against the simply change from >> to >, because i have other entries in the /var/spool/cron/crontabs/root and don't override it.

I think the most people start the container and let it running. If it starts rare, it hasn't been noticed yet ;-).

Workaround (used by me)

I used the following workaround for me and changed the lines to

# logrotate
grep -qsF "seafile" /var/spool/cron/crontabs/root || cat /scripts/logrotate-conf/logrotate-cron >> /var/spool/cron/crontabs/root # changed!
grep -qsF "DO NOT EDIT THIS FILE" /var/spool/cron/crontabs/root || /usr/bin/crontab /var/spool/cron/crontabs/root # changed!

These both changes applies only the first execution time, where the file not exists. The further times (like restarts), the containing "seafile" or "DO NOT EDIT THIS FILE" avoid to process the || part.

Concern

Can you please fix this with my workaround or with a other proper solution (regarding keep existing entries)?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions