Forum Moderators: coopster

Message Too Old, No Replies

proper way to end/exit/close php file?

         

brandon0401

11:17 pm on Sep 13, 2007 (gmt 0)

10+ Year Member



Hey guys, I have a php file that runs every 10 minutes via cron.

/usr/bin/php -q /home/user/file.php

I have been noticing that that there are multiple versions of it left open in memory it seems(by looking at top -c)

The file is basically a php files that compares and updates a mysql db.

I am not doing anything to end the file..

What is the proper way of doing this...

php

and then

if needed

mysql..

Dont see a bunch of open mysql connections though

Trying to make this file efficient as possible as it can drag down the server when it runs for 5-10 min

Thanks in advance!

B

eelixduppy

12:11 am on Sep 14, 2007 (gmt 0)



For mysql you can use mysql_close [php.net]() however this should be called anyway at the conclusion of the script. I do not know why you are seeing multiple php scripts executing unless they are getting hung up by something you coded.

brandon0401

2:57 am on Sep 14, 2007 (gmt 0)

10+ Year Member



I dont see anything that would get hung up and its functioning ok, and finishing the mysql statements....how could I see that? thanks

jatar_k

3:09 pm on Sep 14, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



the multiples could just be becaues it takes longer than 10 mins to execute and then you run it again which may cause the first one to die

you could try extending the times between executions to see if that helps to identify.

Those files could also be hanging as eelix mentioned, it's very difficult to figure out why. You could make it verbose by adding a ton of echos for each step and then run it from the command line and see what it does. You may be able to identify something that way.