Michdd Posted November 26, 2008 Share Posted November 26, 2008 I was wondering if there would be a problem using an include(); function to include a connection to a database when using CRON. I'm trying to use CRON jobs to run a script every 12 hours that dumps all the values from a certain row in my database, when I run the script myself it works perfectly, but when I use CRON it doesn't work. Only thing I can think of is that CRON jobs has a problem including the connect.php file, anyone know why it isn't working? Link to comment https://forums.phpfreaks.com/topic/134393-certain-php-functions-cron/ Share on other sites More sharing options...
flyhoney Posted November 26, 2008 Share Posted November 26, 2008 include() should definitely work in a CRON job. I would imagine the problem lies elsewhere. Link to comment https://forums.phpfreaks.com/topic/134393-certain-php-functions-cron/#findComment-699658 Share on other sites More sharing options...
Michdd Posted November 26, 2008 Author Share Posted November 26, 2008 include() should definitely work in a CRON job. I would imagine the problem lies elsewhere. Any idea where? I've used CRON on other things before, and it surely works. Just not with this.. Link to comment https://forums.phpfreaks.com/topic/134393-certain-php-functions-cron/#findComment-699659 Share on other sites More sharing options...
Mark Baker Posted November 26, 2008 Share Posted November 26, 2008 Check the path. In fact, check the php.ini file that you're using for command line PHP scripts. Link to comment https://forums.phpfreaks.com/topic/134393-certain-php-functions-cron/#findComment-699669 Share on other sites More sharing options...
trq Posted November 26, 2008 Share Posted November 26, 2008 Are you using absolute paths within your include? Cron doesn't run from where the actual php file is located so relative paths won't work. Link to comment https://forums.phpfreaks.com/topic/134393-certain-php-functions-cron/#findComment-699670 Share on other sites More sharing options...
Michdd Posted November 26, 2008 Author Share Posted November 26, 2008 Are you using absolute paths within your include? Cron doesn't run from where the actual php file is located so relative paths won't work. Thanks a lot, I believe you solved this, I'll just write in the connect information in the file instead of including it, I'll try that right now. Link to comment https://forums.phpfreaks.com/topic/134393-certain-php-functions-cron/#findComment-699671 Share on other sites More sharing options...
Michdd Posted November 26, 2008 Author Share Posted November 26, 2008 That didn't work, the code in the file is this: <?php --Connect information-- $result = mysql_query("UPDATE pets SET ips=''") or die(mysql_error()); ?> It works perfectly when I just run it normally, but not when I use CRON :| Link to comment https://forums.phpfreaks.com/topic/134393-certain-php-functions-cron/#findComment-699680 Share on other sites More sharing options...
Mark Baker Posted November 26, 2008 Share Posted November 26, 2008 Check the version of php that's being run from the command line (php -v), and that mySql is enabled for that version Link to comment https://forums.phpfreaks.com/topic/134393-certain-php-functions-cron/#findComment-699816 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.