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? Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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? Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.