0
I am trying to run a routine by crontab, but it hangs on the connection to the Database. But if I run the file normally as:
php /var/www/html/pasta/teste.php
He returns the data to me normally:
This is my crontab:
*/1 * * * * /usr/bin/php /var/www/html/pasta/teste.php >> /var/log/teste.log
This is my php file:
<?php
echo 'Iniciou.. ';
try{
echo 'Vai conectar?.. ';
$connection = oci_connect('user' , 'password', 'HOST/DB');
echo 'Conectou.. ';
} catch (PDOException $e)
{
$mensagem .= " Erro: " . $e->getMessage();
echo $mensagem;
}
$sql = "SELECT * FROM tabela where rownum <= 2";
$querySQL = oci_parse($connection, $sql);
oci_execute($querySQL);
oci_fetch_all($querySQL, $stmt);
foreach($stmt as $row)
{
var_dump($row) ;
exit;
}
?>
The crontab result looks like this (/var/log/test.log):
Iniciou.. Vai conectar?..
Version of the OS:
VERSION="18.04.2 LTS (Bionic Beaver)"
PRETTY_NAME="Ubuntu 18.04.2 LTS"
VERSION_ID="18.04"