简体   繁体   English

Jelastic Cron工作调用PHP脚本

[英]Jelastic Cron job to call PHP script

I am trying to run a PHP script via a cron job on a Jelastic server. 我试图在Jelastic服务器上通过cron作业运行PHP脚本。 My cron/apache file looks like this. 我的cron / apache文件如下所示。

*/1 * * * * /usr/bin/php /var/www/webroot/ROOT/php/cron.php

(there is a blank line after the last cronjob entry) (在最后的cronjob条目之后有一个空白行)

However the script is not called by the cron job. 但是,cron作业不会调用该脚本。 I have read the Jelastic documentation for cron jobs ( http://docs.jelastic.com/cron-job ) but this hasn't helped me resolve the issue. 我已经阅读了有关cron作业的Jelastic文档( http://docs.jelastic.com/cron-job ),但这并没有帮助我解决问题。

Any help would be appreciated. 任何帮助,将不胜感激。

As you said the script is accessible by HTTP, you could try using this cron job instead: 正如您所说的,该脚本可通过HTTP访问,您可以尝试使用以下cron作业:

*/1 * * * * wget -q http://www.example.com/cron.php

This will perform at GET request to the cron.php file and disregard the output. 这将在GET请求下对cron.php文件执行,而忽略输出。

You can already get SSH access on the Layershift Jelastic PaaS: http://kb.layershift.com/jelastic-ssh-access 你已经可以得到关于Layershift Jelastic的PaaS SSH访问: http://kb.layershift.com/jelastic-ssh-access

Assuming you're using a different provider, you might try writing cron output to a log file like 假设您使用的是其他提供程序,则可以尝试将cron输出写入日志文件,例如

*/1 * * * * /usr/bin/php /var/www/webroot/ROOT/php/cron.php >> /var/log/httpd/cron.log

And/or you can try to mail the output to yourself (but beware mailing caveats; without a public IP your mail will "originate" from the physical server's IP instead, and that may or may not have a valid PTR record defined or be on blacklists etc. - so basically there's a good chance your spam filters may reject the email); 和/或您可以尝试将输出邮寄给自己(但要注意邮寄警告;如果没有公共IP,则您的邮件将“起源”于物理服务器的IP,并且可能会或可能不会定义有效的PTR记录黑名单等-基本上,您的垃圾邮件过滤器很有可能会拒绝电子邮件); just add this line to your crontab: 只需将此行添加到您的crontab中:

MAILTO=you@youremail.com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM