title: Php script not running with www-data cron
body: <p>after a week of trying i dont know what else to do.
  I have a simple php script that is on my webserver called getpoem.php
  The script opens up a website pulls its content and saves it to a poem.txt on the server </p>
  
  <pre><code>&lt;?php
      //File to extract the Poem of the day
      $homepage = file_get_contents('http://SomeWebsite.com/today.php');
      $poemALL = substr($homepage,strpos($homepage,"&lt;p&gt;"),strlen($homepage));
      .
      .  // extracting the poem and saving it to $poemFinish
      .
      file_put_contents("poem.txt", $poemFinish); ?&gt;
  </code></pre>
  
  <p>so this is a fairly simple script (it works fine if i manually execute it). This script should be executed with the www-data user with its cron so i opend up cron with this command and entered the command it should run</p>
  
  <pre><code>sudo crontab -u www-data -e 
  
  0 3 * * * php /var/www/html/getpoem.php
  </code></pre>
  
  <p>to avoid any permission problems i gave the getpoem.php and poem.txt rwx rights like this (i know i should change it when its live but this is just to test)</p>
  
  <pre><code>-rwxrwxrwx 1 www-data www-data 1189 Aug 17 15:07 getpoem.php
  -rwxrwxrwx 1 www-data www-data 1335 Aug 17 15:07 poem.txt
  </code></pre>
  
  <p>So this is the setup, but it will not execute.</p>
  
  <p>What i did so far changing the "php" to /usr/bin/php to secure that cron know what php is. 
  Next thing i did was making shure that cron was running so i changed the cronjob to </p>
  
  <pre><code>2 * * * */usr/bin/php /var/www/html/getpoem.php | &gt; /var/www/html/test.txt
  </code></pre>
  
  <p>wich again did nothing .... so i changed it to </p>
  
  <pre><code>2 * * * */usr/bin/php /var/www/html/getpoem.php | &gt; /tmp/test.txt
  </code></pre>
  
  <p>that did not run the php file but created a empty (-.-") file called test.txt in my tmp dir.</p>
  
  <p>So i think the problem must be someware in the acces rights of my www-data user. It's just very wierd because all my webcontent (php files, webapp usw.) are also owned by the www-data user and they run smoothly.</p>
  
  <p>Do i need to grand extra privileges for the cron of www-data ?</p>