How to run server script continuously and send the updated data

Hello Everyone,

I am working on site creation and I am newbie with this work. I have used php for creating my site.I want to create server script that run on my machine continuously and send the updated data to the client who want that data. I have created two sample code one is Server.php and another is Client.php.

Server.php

<?php session_start(); $_SESSION['Argument'] = 10; while(1) { print "Updated data in Server Script ".$_SESSION['Argument']; $_SESSION['Argument'] += 20; sleep(5); } ?>

Client.php

<?php session_start(); print "Updated data in Client Script ".$_SESSION['Argument'] ; ?>

I want to run the Serever.php without using browser and as a background process. When I will run Client.php from browser, I want the updated data every time.Is it possible ?

Because, I was run Server.php through command prompt it run but, when I run Client.php script through browser then it return error “Notice: Undefined index: Argument in Client.php”. I was searched about this problem I was found that due to different session_id Client.php script didn’t identify the session variable of Server.php.

After that I was run my server script by usiong “wget http://localhost/Server.php” through command line because I thought that apache maintian the session variable or session_id. But still I got same notice. I was never used cron method because it run script periodically not continuously.

Is there is any way to solve my problem please help me. I was suffered from last 4 days.

Thanks and Regard,
Antrikssh… :slight_smile:

Look into cron jobs.

Sponsor our Newsletter | Privacy Policy | Terms of Service