php cron job läuft nicht [duplizieren]
Diese Frage hat hier bereits eine Antwort:
cronjob führt kein Skript aus, das einwandfrei funktioniert. 2 Antwortenroot@xx:/var/www/test# which php
/usr/bin/php
root@xx:/var/www/test# ls -la
total 16
drwxrwxrwx 2 root root 4096 Nov 14 09:37 .
drwxrwxrwx 6 root root 4096 Nov 13 15:51 ..
-rwxrwxrwx 1 root root 153 Nov 14 09:35 test.php
Das ist meintest.php
Datei
<?php
$my_file = 'file.txt';
$handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file); //implicitly creates file
Und dies ist die Ausgabe voncrontab -l
:
#this is ok
* * * * * touch /tmp/hello
#this only creates an empty php_result.log
* * * * * /usr/bin/php /var/www/test/test.php > /tmp/php_result.log
root@xx:/var/www/test# php -v
PHP 5.4.34-0+deb7u1 (cli) (built: Oct 20 2014 08:50:30)
Der Cron-Job wird nicht ausgeführt, und das Problem liegt bei PHP. Wenn ich die Datei manuell starte, funktioniert alles gut.
php test.php
Verwandte Frage: Warum führt crontab mein PHP-Skript nicht aus?.