GithubHelp home page GithubHelp logo

Comments (8)

mblaschke avatar mblaschke commented on August 19, 2024 2

we should implement go-crond to get rid of the environment issue :)

from php-docker-boilerplate.

kyrilg avatar kyrilg commented on August 19, 2024 1

Hi @nverhoye,
Environments differs between shell and crontab, you can check it with printenv in shell / crontab

https://serverfault.com/questions/337631/crontab-execution-doesnt-have-the-same-environment-variables-as-executing-user

I use approach 2

Try something like this:
* * * * * application . ~/.profile; /usr/local/bin/php /app/foo.php

from php-docker-boilerplate.

mblaschke avatar mblaschke commented on August 19, 2024 1

The environment parameters are not passed to cronjobs. They are filtered by default and AFAIK there is no way to fix this other then replacing the cron daemon.

I will replace cron with gocrond this weeks to get rid of this stupid issue

from php-docker-boilerplate.

abagayev avatar abagayev commented on August 19, 2024 1

Hey, I just created an example of how to use crontab with webdevops docker-compose, you can check it our here:
https://github.com/abagayev/docker-bootstrap-collection/tree/master/crontab-in-container

from php-docker-boilerplate.

nverhoye avatar nverhoye commented on August 19, 2024

Hi @kyrilg

Thanks for your reply, but it still does not work unfortunately.

I pushed
* * * * * application . ~/.profile; /usr/local/bin/php /app/foo.php

Instead of

# m h  dom mon dow  user  command
* * * * * php /app/foo.php

No result :(

from php-docker-boilerplate.

mblaschke avatar mblaschke commented on August 19, 2024

please make sure you have an empty line at the end (cron requirement).. otherwise your crontab is ignored, also make sure the permissions are correct and not world writeable.

go-crond will fix this with correct error messages.

from php-docker-boilerplate.

nverhoye avatar nverhoye commented on August 19, 2024

Hi @mblaschke, i have an empty line at the end (cron requirement), also permissions are correct (0644).

Below crontab used now :

* * * * * application . /home/application/.profile; /bin/bash /app/scheduler_cron.sh --mode always >> /app/cron.log 2>&1
# An empty line is required at the end of this file for a valid cron file.

NOW file is executed, but file can't do works asked. I have message returned : "Could not find a binary for php"

This is content of scheduler_cron.sh :

#!/bin/bash

# Generate an error if any variable doesn't exist
set -o nounset

# Location of the php binary
PHP_BIN=$(which php || true)

if [ -z "${PHP_BIN}" ]; then
    echo "Could not find a binary for php" 1>&2
    exit 1
fi

In cron task "which php" return empty
BUT when i'm connected to docker's container it return '/usr/local/bin/php'

See :

docker exec -it app bash
root@03dc0dd62e77:/$ su application
application@03dc0dd62e77:/$ which php
/usr/local/bin/php

Any ideas ? Thanks

from php-docker-boilerplate.

nverhoye avatar nverhoye commented on August 19, 2024

Hi @mblaschke, can you share the solution ? Thanks

from php-docker-boilerplate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.