PHP:尝试通过Cron作业运行脚本时出错 [英] PHP: Error trying to run a script via Cron job

查看:174
本文介绍了PHP:尝试通过Cron作业运行脚本时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过控制面板设置了cron作业。我已经通过我的FTP上传脚本,设置它的权限为777(这是安全吗?)&在作业中给出了此脚本的路径。现在脚本使用相关脚本能够运行作业。混乱?这是它的样子:

I have setup a cron job via my Control panel. I have uploaded the script via my FTP, set up it's permission as 777 (is it safe to do so?) & gave the path to this script in the job. Now the script makes use of dependent scripts to be able to run the job. Confusing? Here's what it's like:

cron.php

<?php require("some_file1.php");
require("file1.php");
require("folder1/file1.php");
require("folder1/file2.php");
require("folder2/file1.php");

//This value is actually received from one of the require files above after come calculations
$get_content = 'This is some value received after calculations.';

mail('Hi', 'email@mydomain.com', $get_content, 'Error');
?>

我已选择接收Cron工作的确认到我的电子邮件&这里是我收到的错误:

I have opted to receive Confirmation of the Cron job to my email & here's the error that I received:

mydomain.com/cron.php: line 1: syntax error near unexpected token `('
mydomain.com/cron.php: line 1: `<?php require("some_file1.php");
'

我尝试和支持人员交谈,但他们不知道这个技术细节,目前技术人员不可用。如果有人可以帮助我,这将是巨大的

I tried talking to the support but they don't have any idea of this technical detail & currently the technical guys are not available. It will be great if someone can help me out here.

期待您的回复。

谢谢。

推荐答案

我能够在网站的技术支持下解决这个问题,这里的解决方案只是为了防止任何人想知道以下是命令运行&需要通过网站的控制面板(GUI)添加。

I was able to solve this with the help of the tech support from the website. Here's the solution just in case anyone was wondering. The following is the "Command to run" & needs to be added via the Control Panel (GUI) of the website.

/usr/local/php5/bin/php 

/home/username/mydomain.com/cron.php

cron.php文件保持不变。

The cron.php file stays the same.

我想我必须接受我自己的答案,因为这是最相关的答案,解。我仍然感谢大家的帮助&欣赏所有的反应。

I guess I am going to have to accept my own answer as this is the most relevant answer which carries the perfect solution. I still do thank you all for your help & appreciate all the responses.

这篇关于PHP:尝试通过Cron作业运行脚本时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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