Skip to content

Instantly share code, notes, and snippets.

@athlan
Last active July 6, 2024 09:31
Show Gist options
  • Select an option

  • Save athlan/b6f09977e2f5cf20840ef61ca3cda932 to your computer and use it in GitHub Desktop.

Select an option

Save athlan/b6f09977e2f5cf20840ef61ca3cda932 to your computer and use it in GitHub Desktop.

Revisions

  1. athlan revised this gist Aug 31, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion crontab.txt
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    * * * * * . /root/.env.sh; /app/bin/console some:symfony_task_here &> /tmp/app-jobs-offers-sync-active.log
    * * * * * bash -c ". /root/.env.sh; /app/bin/console some:symfony_task_here &> /tmp/app-jobs-offers-sync-active.log"
  2. athlan revised this gist Aug 31, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion crontab.txt
    Original file line number Diff line number Diff line change
    @@ -1 +1 @@
    * * * * * /root/.env.sh; /app/bin/console some:symfony_task_here &> /tmp/app-jobs-offers-sync-active.log
    * * * * * . /root/.env.sh; /app/bin/console some:symfony_task_here &> /tmp/app-jobs-offers-sync-active.log
  3. athlan created this gist Aug 31, 2019.
    12 changes: 12 additions & 0 deletions Dockerfile
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    FROM XXXX

    #Install cron
    RUN apt-get update; \
    apt-get install -y cron; \
    apt-get clean; \
    touch /var/log/cron.log

    COPY crontab.txt /etc/cron.d/crontab
    COPY run-cron.sh /usr/local/app/entrypoint/run-cron.sh

    CMD ["/usr/local/app/entrypoint/run-cron.sh"]
    1 change: 1 addition & 0 deletions crontab.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    * * * * * /root/.env.sh; /app/bin/console some:symfony_task_here &> /tmp/app-jobs-offers-sync-active.log
    13 changes: 13 additions & 0 deletions run-cron.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    #!/bin/bash

    ENV_VARS_FILE="/root/.env.sh"

    echo "Dumping env variables into ${ENV_VARS_FILE}"
    printenv | sed 's/^\(.*\)$/export \1/g' > ${ENV_VARS_FILE}
    chmod +x ${ENV_VARS_FILE}

    echo "Applying crontab"
    crontab /etc/cron.d/crontab

    echo "Running crontab"
    cron -f