Skip to content

Instantly share code, notes, and snippets.

@rordi
Last active October 24, 2017 14:26
Show Gist options
  • Save rordi/d7b54b08e39baf9bc85b546850d52b63 to your computer and use it in GitHub Desktop.
Save rordi/d7b54b08e39baf9bc85b546850d52b63 to your computer and use it in GitHub Desktop.
Give crontab access to env variables of www-data user within a Docker container

Give crontab access to env variables of www-data user within a Docker container

docker entrypoint

CRON_ENV=/var/www/env.sh
printenv | sed 's/^\(.*\)$/export \1/g' > ${CRON_ENV}

or

CRON_ENV=/var/www/env.sh
printenv | sed 's/^\(.*\)$/export \1/g' | grep VAR_NAME > ${CRON_ENV}

crontab

  CRON_ENV=/var/www/env.sh
  0,30 * * * * . $CRON_ENV; /usr/local/bin/php /app/bin/console my:symfony:command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment