I am trying to connect to mysql database in a PHP script run via cron job. It does not connect to the database somehow. I run the same script in my browser and everything works well. I use free BSD and following is the piece of code I try to run:
ini_set(max_execution_time,1200);
require_once("../settings.php");
$query = "insert into cron_log values(null, '". date("D d-m-Y") ."')";
mysql_query($query);
exec("convert /usr/local/www/demo/cron/test.pdf /usr/local/www/demo/cron/1.jpg");
If I run the above script via cron, it does nothing.
If I run above script in browser, it creates new row in table as well as creates 1.jpg.
If I remove the Database part and run it via cron, it creates the 1.jpg file.
What can be the possible cause and solution?
file_put_contents('test.txt', 'Cron works'); die();put this in first line.require_onceorrequire_once(dirname(__FILE__).'/../settings.php');