Can I set the priority of running a PHP script in CLI mode through configuration in an ini file or directly from a script?

I mean settings that can be changed from the task manager, for example, "realtime" or "idle". My script uses a lot of resources and cripples graphics programs that work at the same time.

I want to set standby priority from a script. I do not need to be 100% faster.

+3
source share
3 answers

On the Windows command line, you have several options:

start /b /low program.exe
start /b /high program.exe
start /b /realtime program.exe
start /b /normal program.exe
start /b /abovenormal program.exe
start /b /belownormal program.exe
+2
source

The answer suggested by @stillstanding is fully valid. I just wanted to add some details from my own experiments.

script 50% CPU, /low, . , . 99-100%, PHP CLI script .

, , , - .

start , exec(), . , 0% .

:

$cmd = 'start /b /low /d "C:\php\" php.exe -f ""C:\Data\www\script.php" foo="1" bar="text"';
pclose(popen($command, "r"));
+1

, PHP pcntl_setpriority(). Unix-only.

Windows; : http://gilchrist.ca/jeff/SetPriority/index.html

You can do exec () in a PHP script to call this program, perhaps.

0
source

Source: https://habr.com/ru/post/1774773/


All Articles