Advertisement
Guest User

shell script to lower process IO priority

a guest
Jun 2nd, 2018
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.69 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # this script scans the system for processes that do too much IO and changes their priority
  4. # to keep them from bogging down the rest of the system
  5.  
  6. # iotop -o -qqq -k -n 2
  7.  
  8. iotop -o -qqq -k -n 2 | awk '{print $1 , $6}' > /run/io_process_list
  9.  
  10. #cat /run/io_process_list
  11.  
  12. #echo end cat
  13.  
  14. file="/run/io_process_list"
  15.  
  16. while IFS= read -r line; do
  17.  
  18.     kilobytes_used=$( echo "$line" | awk '{ print $2 }' | awk -F"." '{ print $1 }' )
  19.  
  20.     #echo kylobites used are $kilobytes_used
  21.  
  22.     if [ $kilobytes_used -gt 10000 ] ; then
  23.  
  24.     ionice -c3 -p$( echo "$line" | awk '{ print $1 }' )
  25.     #echo "$line" | awk '{ print $1 }'
  26.  
  27.     fi
  28.  
  29.     #printf '%s\n' "$line"
  30. done < "$file"
  31.  
  32. rm "$file"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement