Page 1 of 1

wanna restrict the cpu usage for my own script

Posted: Tue Sep 05, 2006 7:08 am
by AngryProphet
Our database transfer script puts the cpu usage on the server (xampp on Win2000) to 95%. This script may run in background. What I want is, that the script pauses so that the server stays available for other users. I tried with usleep(30) but the result is not very impressing. Does anybody solved a similar problem with a proper solution?

Posted: Tue Sep 05, 2006 7:23 am
by feyd
usleep(30) is a sleep of 30 microseconds. Hardly enough time for the OS to take any amount of clock back before being interupted. I'd increase the amount you pass to it be a LOT. There's always sleep() too.

Posted: Tue Sep 05, 2006 10:13 am
by AngryProphet
Thx, feyd.

So the idea wasn´t that bad, just the amount of time was stupid?

kk, i´ll change that.