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.

Šimon Marko
  • 69
  • 1
  • 11

2 Answers2

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
Azhar
  • 75
  • 1
  • 4
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
Trutch70
  • 123
  • 8