为什么cron不会正确执行我的PHP脚本? [英] Why won't cron execute my PHP script correctly?

查看:242
本文介绍了为什么cron不会正确执行我的PHP脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PHP脚本(只是一个简单的脚本),我试图让它作为cronjob运行。每次它执行PHP脚本,我收到一个邮件与PHP脚本本身。

I've got a PHP script (just a simple script) and I'm trying to get it to run as a cronjob. Every time it executes the PHP script, I receive a mail with the PHP script itself.

我如何解决这个问题?我在Google上搜索了很多,但我找不到任何有效的。

How can I resolve this? I've searched on Google a lot but I can't find anything that works.

推荐答案

在DirectAdmin面板中,转到cronjobs部分,我们假设您已经为cronjob配置了时间间隔,需要调整命令选项,请尝试:

In your DirectAdmin panel go to 'cronjobs' section, I assume you already configured time interval for your cronjob, so you just need to adjust 'command' option, so try:

第一个选项

/usr/bin/php -f /home/your_user/public_html/your_script.php

这样,您将使用php解释器调用php脚本。

This way you will call php script with php interpreter.

第二个选项

lynx -source http://yourdomain.com/your_script.php

这样,您将执行基于文本的Web浏览器lynx并打开所需的URL,以便可以运行php脚本。 Lynx默认安装在大多数linux服务器上。

This way you will execute text based web browser lynx and open desired url so that php script can be run. Lynx is installed by default on most linux servers.

同时我相信DirecAdmin cronjobs部分有一个选项'防止电子邮件'检查,这样你就不会接收电子邮件。

Also I believe that there is a option in DirecAdmin cronjobs section called 'Prevent email' check that so that you don't receive emails.

这篇关于为什么cron不会正确执行我的PHP脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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