Crontab issue
Opened this issue · 7 comments
hotrush commented
I can see this during image build
Step 5/39 : RUN (crontab -l ; echo "* * * * * /usr/local/bin/php /srv/app/artisan schedule:run >> /dev/null 2>&1") | crontab
---> Running in 224010ada790
no crontab for root
dragonfire1119 commented
@hotrush I had the same problem had to alter the code a bit.
# Add crontab file in the cron directory
ADD ./.deploy/config/schedule/crontab /etc/cron.d/cron
# Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/cron
# Create the log file to be able to run tail
RUN touch /var/log/cron.log
# Run the command on container startup
CMD printenv > /etc/environment && echo "cron starting..." && (cron) && : > /var/log/cron.log && tail -f /var/log/cron.log
darr1s commented
@dragonfire1119 mind sharing where do you place these lines?
dragonfire1119 commented
@darrist Placed it right under
# RUN (crontab -l ; echo "* * * * * /usr/local/bin/php /srv/app/artisan schedule:run >> /dev/null 2>&1") | crontab
darr1s commented
I have this:
RUN apt-get update && apt-get install -y build-essential cron curl locales zip unzip git
# Setup cron job
# RUN (crontab -l ; echo "* * * * * /usr/local/bin/php /srv/app/artisan schedule:run >> /dev/null 2>&1") | crontab
# Add crontab file in the cron directory
ADD ./.deploy/config/schedule/crontab /etc/cron.d/cron
# Give execution rights on the cron job
RUN chmod 0644 /etc/cron.d/cron
# Create the log file to be able to run tail
RUN touch /var/log/cron.log
# Run the command on container startup
CMD printenv > /etc/environment && echo "cron starting..." && (cron) && : > /var/log/cron.log && tail -f /var/log/cron.log
# Install supervisord
COPY --from=ochinchina/supervisord:latest /usr/local/bin/supervisord /usr/local/bin/supervisord
.deploy/config/scheduler/crontab:
* * * * * /usr/local/bin/php /srv/app/artisan schedule:run >> /dev/null 2>&1
Will report back if its working. Thanks!
darr1s commented
Cron doesn't seem to be running.
hotrush commented
Haven't tested it yet, but i tried another approach from here https://github.com/thelebster/docker-cron/blob/master/ubuntu/Dockerfile
And it doesn't work too... So painful to make it works
jackbrycesmith commented
Would recommend trying out all the latest changes on the master branch following the move to the alpine image & running all services as a non-root user in #5.