简体   繁体   English

电子邮件无法通过Cron作业获取

[英]Email not getting via cron job

<?php
    mail('myemail@example.com', 'Test email', 'Test cron running');
    ?>

test_email.php have above code, when i run this file manually (via URL) then i received email but via cron job i am not getting email. test_email.php具有上面的代码,当我手动运行此文件(通过URL)时,我收到了电子邮件,但通过cron作业我没有收到电子邮件。

* * * * * /usr/bin/php /home/test/public_html/bs/cron/test_email.php >> /home/test/public_html/test_email.log & 

* * * * * curl --silent -o /dev/null http://www.example.com/cron/test_email.php

I used both cron command but no result. 我都使用了cron命令,但没有结果。 Can anyone guide me where is the problem in the code? 谁能指导我代码中的问题在哪里?

试试这个:

* * * * * php /home/test/public_html/bs/cron/test_email.php

If your script is working but not in your cron, it looks like your cron table is not aware of your changes 如果您的脚本可以运行,但不在您的cron中,则您的cron表似乎不知道您所做的更改

Did you try restarting it with 您是否尝试使用重新启动它

sudo service cron restart

or 要么

sudo /etc/init.d/cron restart

?

I am using this command to run my cron job : 我正在使用以下命令运行我的cron作业:

wget -O /dev/null http://www.example.com/cron/test_email.php wget -O / dev / null http://www.example.com/cron/test_email.php

If you really stock in that situation , try calling the attention of support of the server that you were using. 如果您确实有这种情况,请尝试引起您所使用服务器的支持。

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

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