使用CronTab运行php脚本 [英] Using CronTab to run php scripts

查看:107
本文介绍了使用CronTab运行php脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要每小时和每天发送一次电子邮件。我几乎尝试了所有操作,但似乎我的crontab无法正常工作。如果我通过浏览器运行脚本,例如

I need to send emails hourly and daily. I've tried nearly everything but it appears my crontab just won't work. If I run the scripts via a browser e.g

http://localhost/Maisha/Functions/sendhourlymails.php  

我的电子邮件发送得很漂亮。(我将默认网站localhost移到了public_html。)我不知道怎么了。我读了一些堆栈溢出的文章,其中包括php的可执行路径,因此我将/ usr / bin / php放在要破坏的实际脚本之前,但是没有用。删除/ usr / bin / php不起作用。在实际脚本无法正常工作之前添加php。
我的crontab中有以下条目。

my emails get sent beautifully.(I moved default website localhost to public_html.) I don't know whats wrong. I read some post in stack overflow including the executable path of php helps hence I've put the /usr/bin/php before the actual script to be cronned will work but it does not. Removing /usr/bin/php does not work. Adding php before the actual script isn't working. I have the following entries in my crontab.

# m h  dom mon dow   command
0  *  *   *   *    /usr/bin/php /home/maxwell/public_html/Maisha/Functions/sendhourlymails.php
0  0  *   *   *    /usr/bin/php /home/maxwell/public_html/Maisha/Functions/senddailymails.php


推荐答案

尝试使用wget通过http调用脚本,如下所示:

Try to call the script via http with wget like so:

* * * * * wget http://mysite.com/myscript >/dev/null 2>&1

这篇关于使用CronTab运行php脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆