1

I'm trying to run cron job with symfony commands. I have this crontab.

* * * * * cd /var/www && /usr/local/bin/php bin/console app:cron:commands > output.txt

I tested if Cron is running by

* * * * * cd /var/www && touch output.txt

this worked and created file.

Then I tried if php is runnig by

* * * * * cd /var/www && /usr/local/bin/php --version > output.txt

this also worked and I got php version output into file output.txt

Last what I tried was

* * * * * cd /var/www && /usr/local/bin/php bin/console about > output.txt

and also now I got output.

I'm trying to figure it out for 2 day's I'm desperate. I can't figure out where is the problem. Symfony command run from command line just fine.

When I was writing this post I run last test I tried to create new test command and use part of the command I can't make run I think was creating problem. It works I don't know why. Difference is only in ownership of the commands. Command I can't run is owned by root and the test command I created is owned by 1000. Can this be the problem?

Edit: I changed ownership to 1000. Nothing change still didn't run from cron.

2
  • try tacking on 2> error.txt Commented Jun 8, 2020 at 19:21
  • @Sammitch I don't understand what to do. Commented Jun 8, 2020 at 19:32

2 Answers 2

1

This probably has the answer: How to use crontab to execute a Symfony command

Try this

* * * * * cd /var/www && /usr/local/bin/php bin/console app:cron:commands > output.txt -e prod
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for reply. This didn't help. I'm in dev environment and even when I try with -e dev, no luck.
0

If you are using the docker container to run php, you might need to use the container in cron:

docker exec -it name_of_your_container php /var/www/example.net/bin/console about > output.txt

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.