简体   繁体   English

无法通过crontab运行的php脚本可以手动正常运行

[英]php script not running via crontab runs fine manually

My script is working fine when I run it into browser but not working when I run it using cron 我的脚本在浏览器中运行时运行良好,但是在使用cron运行时却无法运行

require_once('/home/dekh/public_html/track/classes/affiliate.class.php');
require_once('/home/dekh/public_html/track/classes/offer.class.php');
require_once('/home/dekh/public_html/track/classes/merchant.class.php');
require_once('/home/dekh/public_html/track/includes/emails.php');
$mer=new Merchant;
$aff=new Affiliate;
$offer=new Offer;
$message = "Line 1\nLine 2\nLine 3";
$message = wordwrap($message, 70);
mail('my email address', 'My Subject', $message);

I get mail when I run it in browser 在浏览器中运行时收到邮件

Here how I've added it in cron 这是我如何在cron中添加它

wget /home/dekh/public_html/track/includes/cron_for_conversions_mail.php
php /home/dekh/public_html/track/includes/cron_for_conversions_mail.php

I've tried it both ways php /home.. and wget /home... 我已经尝试了两种方式php / home ..和wget / home ...

Please suggest thanks 请建议谢谢

wget url but not a local file wget url但不是本地文件

just like: 就像:

  http://127.0.0.1/cron_for_conversions_mail.php

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

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