Page 1 of 1
xampp php.ini
Posted: Fri Sep 04, 2009 3:06 am
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?

Re: xampp php.ini
Posted: Fri Sep 04, 2009 4:40 am
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?
Re: xampp php.ini
Posted: Fri Sep 04, 2009 4:46 am
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.

Re: xampp php.ini
Posted: Fri Sep 04, 2009 4:54 am
by dude81
why not loop the calls for one minute with in the script? Then call every minute cronjob until 9 hours? via crontab
Re: xampp php.ini
Posted: Fri Sep 04, 2009 5:09 am
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?

Re: xampp php.ini
Posted: Fri Sep 04, 2009 5:18 am
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?

Windows Scheduler (as attached image)
php.bat is
Code: Select all
C:\xampp\php\php %1 %2 %3 %4 %5 %6 %7 %8 %9
Re: xampp php.ini
Posted: Fri Sep 04, 2009 6:33 am
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"

Re: xampp php.ini
Posted: Fri Sep 04, 2009 7:03 am
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...

Re: xampp php.ini
Posted: Fri Sep 04, 2009 7:05 am
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?

Re: xampp php.ini
Posted: Fri Sep 04, 2009 7:19 am
by Mark Baker
jorgeng wrote:dude81 wrote:Another question, how to build a loop that executes in 60 seconds and then stops in php?

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) {
...
}
Re: xampp php.ini
Posted: Fri Sep 04, 2009 8:48 am
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.

Re: xampp php.ini
Posted: Fri Sep 04, 2009 9:06 am
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.

Re: xampp php.ini
Posted: Fri Sep 04, 2009 9:51 am
by Mark Baker
Then set $endTime = $timeNow + 55; or start your code with set_time_limit(65);
Re: xampp php.ini
Posted: Tue Sep 08, 2009 2:44 pm
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?
