English 中文(简体)
Cronjob 呼叫无响应的 php 函数
原标题:cronjob calling a php function not responding
  • 时间:2012-05-24 01:18:17
  •  标签:
  • php
  • cron

我有一个叫 php 脚本的Cronjob 。 cronjob 正在执行中, 因为它设置在发送电子邮件 。 phop 脚本在手动执行时正常工作 。 我相信它可能与权限有关, 但我不确定如何检查是否属于这种情况 。 我使用教父 。

以下是 php 脚本 :

$dayOfWeek = date( w );

if($dayOfWeek == 1) $xml = file_get_contents( http://xxxxx.com/mon.xml );
if($dayOfWeek == 2) $xml = file_get_contents( http://xxxxx.com/tues.xml );
if($dayOfWeek == 3) $xml = file_get_contents( http://xxxxx.com/wed.xml );
if($dayOfWeek == 4) $xml = file_get_contents( http://xxxxx.com/thurs.xml );
if($dayOfWeek == 5) $xml = file_get_contents( http://xxxxx.com/fri.xml );
if($dayOfWeek == 6) $xml = file_get_contents( http://xxxxx.com/sat.xml );
if($dayOfWeek == 7) $xml = file_get_contents( http://xxxxx.com/sun.xml );

file_put_contents( Bars.xml , $xml);

mysql_connect("xxxx.hostedresource.com", "user", "userpw") or die(mysql_error());   
mysql_select_db("dbname") or die(mysql_error());

mysql_query("UPDATE mytable SET isWorking= 0  WHERE isWorking= 1 ") or die(mysql_error());  

我收到以下错误信息:

   <br />
    <b>Warning</b>:  file_get_contents(http://xxxxxx.com/fri.xml) [<a href= function.file-get-contents >function.file-get-contents</a>]: failed to open stream: 
HTTP request failed! HTTP/1.0 403 Forbidden
     in <b>/home/content/77/8761477/html/refreshXML.php</b> on line <b>8</b><br />

有什么建议吗?

谢谢 谢谢

问题回答

Why it s failing ? Check on /var/log/cron for better error output...

Check if your PHP command is reachable from cronjob. I would try to call php as /usr/bin/php not only php command itself.

希望有帮助





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签