OVH CRON:如何执行Symfony命令?

OVH CRON:如何执行Symfony命令?

问题描述:

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.

如何使用OVH cron执行Symfony命令?
我在symfony项目上创建了一个命令: p>

  php bin / console cron:test 
  code>  pre> 
 
 

我在OVH表“Scheduled Tasks - Cron”中定义了我的Cron: p>

  • 命令:cron / test.sh li>
  • 语言: 其他 li> ul>

    test.sh是可执行的(chmod 700)。 p>

    在test.sh我不知道 写什么。 strong>
    我在互联网上测试了几个没有成功的代码,包括这个(带有一个php文件): OVH cron jobs / Symfony命令 p>

    我正在使用php 7.1。 什么是适用于查找此内容的逻辑 码? 在此先感谢您的帮助。 p> div>

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

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.