php cron job não executando [duplicado]
Esta pergunta já tem uma resposta aqui:
cronjob não executa um script que funcione bem autônomo 2 respostasroot@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
Este é meutest.php
Arquivo
<?php
$my_file = 'file.txt';
$handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file); //implicitly creates file
E esta é a saída decrontab -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)
O trabalho cron não será executado, e o problema está no php. Se eu executar o arquivo manualmente, tudo funcionará be
php test.php
Pergunta relacionada:Por que o crontab não está executando meu script PHP?.