1

How to execute a Symfony command with OVH cron?
I created a command on my symfony project:

php bin/console cron:test

I defined my Cron in the OVH table "Scheduled Tasks - Cron":

  • Command: cron/test.sh
  • Language: Other

test.sh is executable (chmod 700).

In test.sh I do not know what to write.
I tested several code found on the internet without success, including this one (with a php file): OVH cron jobs / Symfony Command

I am using php 7.1. What is the logic that applies to find this code? Thanks in advance for the help.

2 Answers2

1

I got my answer. Thank you @Tomasz for your help.
phpinfo() showed me the way.
The solution:

 #!/bin/bash 
/usr/local/php7.1/bin/php /homez.ovhNumber/myWebsite/symphonyProject/bin/console cron:test
0

In command field you should be able to enter command you want to execute. But because you don't know from where it will be executed you have to specify full path to command for example:

php /var/www/my-project/bin/console cron:test

But, I'm not familiar with OVH Tools so if you need to create bash file which will be run by cron, then your file should like like this:

#!/bin/bash

php /var/www/my-project/bin/console cron:test

Here is the same principal with the full path to your bin/console file.

Tomasz
  • 4,847
  • 2
  • 32
  • 41
  • Thank you for your answer. Yes OVH needs a bash file which will be run by cron. In your example I don't know what to put instead of var. I guess it's OVH path but I don't know it. – Florent Barbet Oct 17 '18 at 11:38
  • @FlorentBarbet Simply you can echo` phpinfo();` in your application to see the full path to your code. then repace it with `/var/www/my-project` – Tomasz Oct 18 '18 at 08:49