The Little Guy Posted March 9, 2010 Share Posted March 9, 2010 I have a script that will run for 2+ days, and what I have noticed is that after a large amount of hours (I don't know the exact amount of hours), the mysql database connection closes and I have to restart the script. I start it, then when I wake up the next morning, it doesn't work and I have to restart the script. how can I make the db connection stay open? Link to comment https://forums.phpfreaks.com/topic/194662-keep-database-connection-open/ Share on other sites More sharing options...
schilly Posted March 9, 2010 Share Posted March 9, 2010 Are you sure it's the db connection? Is there a max execution time in the mysql config? How are you running this? Won't you hit the PHP max executing time? If you can, it would be much better to do whatever you're doing in batches. Link to comment https://forums.phpfreaks.com/topic/194662-keep-database-connection-open/#findComment-1023758 Share on other sites More sharing options...
The Little Guy Posted March 9, 2010 Author Share Posted March 9, 2010 I know it is the database, because after a certain amount of time with use the script still works but nothing gets inserted into the database. Link to comment https://forums.phpfreaks.com/topic/194662-keep-database-connection-open/#findComment-1023773 Share on other sites More sharing options...
schilly Posted March 9, 2010 Share Posted March 9, 2010 i would check your my.cnf file to see if there is a flag in there. Link to comment https://forums.phpfreaks.com/topic/194662-keep-database-connection-open/#findComment-1023779 Share on other sites More sharing options...
The Little Guy Posted March 9, 2010 Author Share Posted March 9, 2010 i would check your my.cnf file to see if there is a flag in there. I don't have access to that file. would mysql_pconnect work? Link to comment https://forums.phpfreaks.com/topic/194662-keep-database-connection-open/#findComment-1023787 Share on other sites More sharing options...
schilly Posted March 9, 2010 Share Posted March 9, 2010 you could try that. why does your script have to run so long? Link to comment https://forums.phpfreaks.com/topic/194662-keep-database-connection-open/#findComment-1023795 Share on other sites More sharing options...
The Little Guy Posted March 9, 2010 Author Share Posted March 9, 2010 because the script is a server daemon Link to comment https://forums.phpfreaks.com/topic/194662-keep-database-connection-open/#findComment-1023847 Share on other sites More sharing options...
The Little Guy Posted March 10, 2010 Author Share Posted March 10, 2010 I tried pconnect, and it didn't work. any other suggestions? Link to comment https://forums.phpfreaks.com/topic/194662-keep-database-connection-open/#findComment-1024020 Share on other sites More sharing options...
roopurt18 Posted March 10, 2010 Share Posted March 10, 2010 Detect when the db connection has gone away and re-open it. Link to comment https://forums.phpfreaks.com/topic/194662-keep-database-connection-open/#findComment-1024088 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.