help in setting up values

I have server, i want to tune some storage below are my issues.

  1. There is a directory
/sys/block/

There are directories starting with name emcpow* under that there is a directory queue, inside that there is file nr_requests

This is complete path

/sys/block/emcpowerbj/queue/nr_requests

i want to change all "[/sys/block/emcpow*/queue/nr_requests]" to like that

echo "100000" > /sys/block/emcpow*/queue/nr_requests 
  1. same thing i want to apply to all emcpow*
echo "noop" > /sys/block/emcpow*/queue/scheduler 
  1. another thing i want to set all emcpow* value to /dev/emcpow* to like that
blockdev --setra 16384 /dev/emcpow* 

---------- Post updated at 12:19 PM ---------- Previous update was at 12:18 PM ----------

point 1 & 2 are almost same, but different is point 3. Please help me out.

The 'for' loop can do what you want.

for BLOCK in /sys/block/emcpow*
do
        echo "100000" > "$BLOCK"/queue/nr_requests
        echo "noop" > "$BLOCK"/queue/scheduler
done

#3 can be solved similarly.

1 Like

will below code is fine?

for BLOCK in /dev/emcpow*

do
       blockdev --setra 16384 "$BLOCK"

done

---------- Post updated at 01:56 PM ---------- Previous update was at 01:55 PM ----------

how can i write above two codes in

1) perl
2) python

Yes, that code looks correct.

I don't see any point doing so in perl, the program would be huge and would end up running 99% shell code anyway.

I don't know Python too well.