How can I lower the priority of CPU and I / O for cron script?

I want to run a script through cron with low I / O and CPU priorities. If I understood correctly (and I couldn’t), I could just add proc_nice(10); in my script to lower the priority of the CPU, but there is no PHP equivalent for I / O priority.

There seems to be an ionice shell command for this, but I'm a Linux idiot and I don't know what I'm doing. Would this be the right line for my cron file if I want to use both nice and ionice to lower the priority of the script?

 0 * * * * /usr/bin/nice -n 10 /usr/bin/ionice -c 3 /path/php/bin/php /path/script.php 

I got the -c3 here ("puts the process in the idle scheduling class"), and I'm not sure what I want.

Is it possible to use a PHP call to proc_nice() instead of this method?

EDIT: my cron script is not working using the above, so I definitely misunderstood something

+6
source share
1 answer

Unix and its clones, as a rule, have an idea about the output of one utility program / command, which becomes the contribution of the next.

In your example, the result (I think) that nice will really affect the pleasantness of ionice . Only the ionice value will affect PHP.

( UPDATE : In fact, it should inherit its appeal, see comment)

I found a page that suggests doing the following so that both nice and ionice affect your PHP instance:

 ionice -c3 -p$$;nice -n 10 /usr/bin/php /path/to/your/script.php 
0
source

All Articles