I need to write a php script which is called by a setInterval( "ajaxrequest('ftp.php', 'context')", 1000 ); function. The php script is fairly easy. It's countain an array of ftp addresses. It loop the array and check every ip address that is online or not.
Here is a sample code of the php script:
$conn_id = ftp_connect("192.168.1.108",21,1) or die ("Cannot connect to the server");
ftp_close($conn_id);
So basically what happens here: We have a javascript which calling a php script every second to check that the ftp servers are online or not. In the PHP script try to connect that if it cant it wrote out "Cannot connect to the server" then it closes the connection.
My problem is that i have to do this way, do not have any chance to use it by cron job because we need to check it trough a web page that the servers are online or not in real time. But in this way somewhere there is a memory leak its eats my memory really fast.
Is there any way that i can release the memory or solve this problem in an other way?