Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crontab issue #10

Open
hotrush opened this issue Oct 20, 2020 · 7 comments
Open

Crontab issue #10

hotrush opened this issue Oct 20, 2020 · 7 comments

Comments

@hotrush
Copy link

hotrush commented Oct 20, 2020

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
Copy link

@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
Copy link

darr1s commented Nov 3, 2020

@dragonfire1119 mind sharing where do you place these lines?

@dragonfire1119
Copy link

@darrist Placed it right under

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

@darr1s
Copy link

darr1s commented Nov 3, 2020

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
Copy link

darr1s commented Nov 5, 2020

Cron doesn't seem to be running.

@hotrush
Copy link
Author

hotrush commented Nov 5, 2020

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
Copy link
Owner

jackbrycesmith commented Dec 8, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants