PHP cron fwrite不行

时间:2016-06-08 08:15:07

标签: php cron

我试试这个:

<?php
$time = time();
$fh = fopen("cron.txt", 'a+');
fwrite($fh, $time);
echo "ok";
?>

在SSH上运行:

/opt/bitnami/php/bin/php /opt/bitnami/apache2/htdocs/cron.php

和远程服务器:

budzinski.xyz/cron.php

在localhost上工作正常,在远程服务器和cron上,不要

2 个答案:

答案 0 :(得分:0)

你的cron命令需要像这样修改 - :

<div class="wrapper">
<div class="bigcontainer">
<img src="http://i1062.photobucket.com/albums/t482/gautam_official/royal-enfield-motorcycle-2x_zpswmyloqvc.jpg" alt="enfield">
</div>
<div class="text">
This is text. Its in center
</div>
</div>

答案 1 :(得分:0)

检查文件的权限是否可写 试试这个例子,看看你是否得到任何输出

<?php
 $filename = 'test.txt';
 $somecontent = "Add this to the file\n";

// Let's make sure the file exists and is writable first.
  if (is_writable($filename)) {

// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
     echo "Cannot open file ($filename)";
     exit;
}

// Write $somecontent to our opened file.
if (fwrite($handle, $somecontent) === FALSE) {
    echo "Cannot write to file ($filename)";
    exit;
}

echo "Success, wrote ($somecontent) to file ($filename)";

fclose($handle);

  } else {
    echo "The file $filename is not writable";
   }
?>