xampp php.ini

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jorgeng
Forum Commoner
Posts: 43
Joined: Mon Aug 04, 2008 8:05 am

xampp php.ini

Post by jorgeng »

I have a php script which is intended to run in webbrowser daily for 9 hours
in a do while loop.

The script checks infile and then send php string to a remote server.

I start it manually in the morning in ie8.
My problem now is that xampp stop to execute the script after 60 seconds.
I have changed in xampp php.ini from 60 seconds to:

max_execution_time = 600000000000000000000000000000000000000

Anyone knowing why this doesn't work, the script stops executing after 60 seconds
and shall loop for 9 hours?
:?
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: xampp php.ini

Post by Mark Baker »

jorgeng wrote:I have a php script which is intended to run in webbrowser daily for 9 hours
in a do while loop. :?
If this has to run in a web browser, then you need to rewrite it so that the web browser does a call every minute (or whatever) to refresh what it's displaying; but the script should simply return data quickly to the browser on each call, without the do while loop.

Alternatively, it should be run as a cron job.

What needs to run for 9 hours?
jorgeng
Forum Commoner
Posts: 43
Joined: Mon Aug 04, 2008 8:05 am

Re: xampp php.ini

Post by jorgeng »

Mark Baker wrote: If this has to run in a web browser, then you need to rewrite it so that the web browser does a call every minute (or whatever) to refresh what it's displaying; but the script should simply return data quickly to the browser on each call, without the do while loop.

Alternatively, it should be run as a cron job.

What needs to run for 9 hours?
Ok, how does the webbrowser do a call every minute to refresh?
Today i read an infile every 2 seconds, and send data via socket to another ip-address.

Can i run cron job every 2 seconds?

What need to run for 9 hours? Yes, this is a stock trading signal system which every 2 seconds send buy or sell orders to another firm by php socket send for my customers.
:?
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

Re: xampp php.ini

Post by dude81 »

why not loop the calls for one minute with in the script? Then call every minute cronjob until 9 hours? via crontab
jorgeng
Forum Commoner
Posts: 43
Joined: Mon Aug 04, 2008 8:05 am

Re: xampp php.ini

Post by jorgeng »

dude81 wrote:why not loop the calls for one minute with in the script? Then call every minute cronjob until 9 hours? via crontab
I will try this. Must i use cron in Windows Vista, can't i just use Windows Vista Scheduler?
And how do i start php script in cron?

:roll:
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: xampp php.ini

Post by Mark Baker »

jorgeng wrote:
dude81 wrote:why not loop the calls for one minute with in the script? Then call every minute cronjob until 9 hours? via crontab
I will try this. Must i use cron in Windows Vista, can't i just use Windows Vista Scheduler?
And how do i start php script in cron?

:roll:
Windows Scheduler (as attached image)

php.bat is

Code: Select all

C:\xampp\php\php %1 %2 %3 %4 %5 %6 %7 %8 %9
Attachments
scheduler.JPG
scheduler.JPG (28.58 KiB) Viewed 360 times
jorgeng
Forum Commoner
Posts: 43
Joined: Mon Aug 04, 2008 8:05 am

Re: xampp php.ini

Post by jorgeng »

I tried this in Windows Vista Scheduler but it won't start..

I don't know what's wrong.
Doesn't i need a web browser to run the php code?

Now my run string looks like this:
"C:\Program Files\xampp\xampp\htdocs\php.bat R.php"

:cry:
jorgeng
Forum Commoner
Posts: 43
Joined: Mon Aug 04, 2008 8:05 am

Re: xampp php.ini

Post by jorgeng »

Update.

Now it works. It's a mess with windows vista when you like me has swedish language, then
you are used that files are running in c:\Program, but in vista it's C:\Program Files in code,
but in explorer it's C:\Program and in dos prompt windows c:\Program Files.

Very confusing...
:banghead:
jorgeng
Forum Commoner
Posts: 43
Joined: Mon Aug 04, 2008 8:05 am

Re: xampp php.ini

Post by jorgeng »

dude81 wrote:why not loop the calls for one minute with in the script? Then call every minute cronjob until 9 hours? via crontab
Another question, how to build a loop that executes in 60 seconds and then stops in php?
8O
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: xampp php.ini

Post by Mark Baker »

jorgeng wrote:
dude81 wrote:Another question, how to build a loop that executes in 60 seconds and then stops in php?
8O
At the very start of your script:

Code: Select all

 
if (file_exists($processLockFileName)) {
    die('Already running');
}
$processLockFileSet = False;
$processLockFileName = 'prc.lck';
 
$processLockFile = fopen($processLockFileName,'w+');
flock($processLockFile,LOCK_EX);
$processLockFileSet = True;
 
and at the very end

Code: Select all

 
if (file_exists($processLockFileName)) {
    if (isset($processLockFile)) {
        flock($processLockFile,LOCK_UN);
        fclose($processLockFile);
    }
    unlink($processLockFileName);
}
 
This prevents the next scheduled run from starting until the current run has completed

Then
once you've tested the lock file at the very beginning of your code:

Code: Select all

 
$timeNow = time();
$endTime = $timeNow + 60;
 
and for your loop:

Code: Select all

 
while (time() < $endTime) {
   ...
}
 
jorgeng
Forum Commoner
Posts: 43
Joined: Mon Aug 04, 2008 8:05 am

Re: xampp php.ini

Post by jorgeng »

[quote="Mark Baker

Code: Select all

 
$timeNow = time();
$endTime = $timeNow + 60;
 
and for your loop:

Code: Select all

 
while (time() < $endTime) {
   ...
}
 
[/quote]

When i run the code the time never updates, became the same whole time and code gets the 60 seconds
error.
:?
jorgeng
Forum Commoner
Posts: 43
Joined: Mon Aug 04, 2008 8:05 am

Re: xampp php.ini

Post by jorgeng »

I run this code:

Code: Select all

 
<?php
$timeNow = time();
$endTime = $timeNow + 60;
 
while (time() < $endTime) {
   echo "hej";
}
 
?>
 
and got error:

hejhejh...........
Fatal error: Maximum execution time of 60 seconds exceeded in C:\Program Files\xampp\xampp\htdocs\test3.php on line 7

so i don't think this code works.
:cry:
Mark Baker
Forum Regular
Posts: 710
Joined: Thu Oct 30, 2008 6:24 pm

Re: xampp php.ini

Post by Mark Baker »

Then set $endTime = $timeNow + 55; or start your code with set_time_limit(65);
jorgeng
Forum Commoner
Posts: 43
Joined: Mon Aug 04, 2008 8:05 am

Re: xampp php.ini

Post by jorgeng »

="Mark Baker]Windows Scheduler (as attached image)

php.bat is

Code: Select all

C:\xampp\php\php %1 %2 %3 %4 %5 %6 %7 %8 %9
Thanks, but i can't get this working in windows vista and xampp.
I have my script in htdocs where i execute them from localhost, but in xampp
i can't run php.exe from /php directory.

My script are located at:
C:\Program Files\xampp\xampp\htdocs

When i write localhost in ie8 i got the page:
http://localhost/xampp/

When i look at files in explorer they are located at c:\Program, but when i copy the directory i got
c:\Program Files, not really sure what i shall have in php script.

Anyone having an idea?
:(
Post Reply