Limit chflags read/write operations using a bash script

I use a bash script that part of it does chflags -R nosimmutable directory and chflags -R simmutable directory.
The directory contains a lot of files/subdirectories and because of mechanical hard disk the system is unresponsive during these operations.

Is any way to use:


rctl -a process:pid:writeiops:throttle=50
rctl -a process:pid:readiops:throttle=50


to limit the read/write operations for chflags?
 
Finally I did it like this:

(rctl -a process:"$BASHPID":writeiops:throttle=50 && rctl -a process:"$BASHPID":readiops:throttle=50 && exec chflags -R nosimmutable directory )
 
Back
Top