使用CronTab运行php脚本

Max*_*axI 2 php crontab

我需要每小时和每天发送电子邮件.我已经尝试了几乎所有的东西,但看起来我的crontab不起作用.如果我通过浏览器运行脚本,例如

http://localhost/Maisha/Functions/sendhourlymails.php  
Run Code Online (Sandbox Code Playgroud)

我的电子邮件发送得很漂亮.(我将默认网站localhost移到了public_html.)我不知道什么是错的.我在堆栈溢出中读了一些帖子,包括php的可执行路径帮助因此我把/ usr/bin/php放在实际脚本之前,cronned会工作,但事实并非如此.删除/ usr/bin/php不起作用.在实际脚本无效之前添加php.我的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
Run Code Online (Sandbox Code Playgroud)

mar*_*kus 6

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

* * * * * wget http://mysite.com/myscript >/dev/null 2>&1
Run Code Online (Sandbox Code Playgroud)