If you use bash and pipes, and are looking for an easy and dirty solution, you can try using sleep
.
You can use this which act like cat
but with a pause at each line. while read i; do echo "$i"; sleep 0.01; done
. Here is an example at a little less than 100 lines per second.
$ time (seq 1 100 | while read i; do echo "$i"; sleep 0.01; done)
[...]
real 0m1.224s
user 0m0.012s
sys 0m0.052s
stat
or /proc/[PID]/mountinfo
should still tell you what the device numbers are:
[root@XXXlin01 block]# stat --printf="%d" /tmp/mnt; echo
24
[root@XXXlin01 block]# stat --printf="%d" /tmp/mnt2; echo
25
[root@XXXlin01 block]# grep "/tmp/mnt" /proc/22195/mountinfo
40 20 0:24 / /tmp/mnt rw,relatime - tmpfs none rw
41 20 0:25 / /tmp/mnt2 rw,relatime - tmpfs none rw
Both outputs show 0:25
and 0:24
as the device numbers in question. The "0" device number is used for "unnamed" mounts (such as tmpfs, sysfs, nfs, procfs, etc). For example, here is an NFS mount:
[root@XXXlin01 block]# grep "/LinuxHome" /proc/22195/mountinfo
39 36 0:23 / /home/jad87 rw,relatime - nfs duhsnas-xxx:/ifs/Application\040File\040Shares/DUHS/LinuxHomeDir_fs/jad87 rw,vers=3,rsize=4096,wsize=4096,namlen=255,soft,proto=tcp,timeo=14,retrans=2,sec=sys,mountaddr=10.1x.92.106,mountvers=3,mountport=300,mountproto=udp,local_lock=none,addr=10.1x.92.106
42 36 0:26 / /home/tsa20 rw,relatime - nfs 10.1x.92.117:/ifs/Application\040File\040Shares/DUHS/LinuxHomeDir_fs/tsa20 rw,vers=3,rsize=4096,wsize=4096,namlen=255,soft,proto=tcp,timeo=14,retrans=2,sec=sys,mountaddr=10.1x.92.117,mountvers=3,mountport=300,mountproto=udp,local_lock=none,addr=10.1x.92.117
The NFS mounts above are 0:23
and 0:26
respectively.
Best Answer
Take a look at
ionice
. Fromman ionice
:To run
du
with the "idle" I/O class, which is the lowest priority available, you can do something like this:This should stop
du
from interfering with other process' I/O. You might also want to consider renicing the program to lower its CPU priority, like so:You can also do both at initialisation time: