laravel-caprover-template icon indicating copy to clipboard operation
laravel-caprover-template copied to clipboard

Crontab issue

Open hotrush opened this issue 4 years ago • 7 comments

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

hotrush avatar Oct 20 '20 21:10 hotrush

@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

dragonfire1119 avatar Oct 24 '20 19:10 dragonfire1119

@dragonfire1119 mind sharing where do you place these lines?

darr1s avatar Nov 03 '20 06:11 darr1s

@darrist Placed it right under

# RUN (crontab -l ; echo "* * * * * /usr/local/bin/php /srv/app/artisan schedule:run >> /dev/null 2>&1") | crontab

dragonfire1119 avatar Nov 03 '20 06:11 dragonfire1119

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 avatar Nov 03 '20 07:11 darr1s

Cron doesn't seem to be running.

darr1s avatar Nov 05 '20 06:11 darr1s

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

hotrush avatar Nov 05 '20 10:11 hotrush

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 https://github.com/jackbrycesmith/laravel-caprover-template/pull/5.

jackbrycesmith avatar Dec 08 '20 17:12 jackbrycesmith