我的 cronjob 不起作用?
也许是一个愚蠢的问题,但我正在尝试让 cronjob 工作。虽然这可能是服务器故障的问题,但我认为这也是一个问题。
反正: 我设置了一个 cronjob,每小时、每天(数字)、每天(名称)和每月 1 分钟执行一次。给定的命令是: /home/easybr01/domains/easybranding.nl/public_html/cronjobs/test.php
这只不过是一个带有简单 php 函数的文件 mail(to, subj, content, hdrs) 来测试它是否有效...但是邮件永远不会进来..而且它们也不在垃圾邮件文件夹中..
有人知道出了什么问题吗?我想这应该是非常简单的......
Maybe a silly question, but I'm trying to get a cronjob to work. Although this could be a question for serverfault I think its also a SO-question.
Anyway:
I have set up a cronjob to be executed everey 1 minute of every hour, day (number), day (name) and month. The given command is: /home/easybr01/domains/easybranding.nl/public_html/cronjobs/test.php
Which is nothing more than a file with a simpe php function mail(to, subj, content, hdrs)
to test if it works... but the mails never come in.. and they're not in a spam folder eighter..
Does someone know what's wrong?? I figured this should be pretty straight forward...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该在 cronjob 中指明 ${PATH_TO_PHP} ,例如:-
或者,您可以使脚本可执行(例如 mod 744),
并将
#!${PATH_TO_PHP}
放入 PHP 脚本的第一行,例如:-You should indicate ${PATH_TO_PHP} into the cronjob, like :-
Alternatively, you can make the script executable (ex. mod 744),
and place
#!${PATH_TO_PHP}
into first line of your PHP script, like :-对于初学者来说,您需要运行 PHP 命令行解释器,而不仅仅是指向 PHP 文件。如果您向 cron 发出命令,它需要整个命令。
For starters, you need to run the PHP command-line interpreter, not just point to a PHP file. If you're giving a command to cron, it needs the whole command.