#91 Renicing Tasks by Process Name
There are many times when it's useful to change the priority of a specific task, whether it's an IRC or chat server that's supposed to use only "spare" cycles, an MP3 player app or file download that has become less important, or a real-time CPU monitor being increased in priority. The renice command, however, requires you to specify the process ID, which can be a hassle. A much more useful approach is to have a script that matches process name to process ID and then renices the specified application.
The Code
#!/bin/sh # renicename - Renices the job that matches the specified name. user=""; tty=""; showpid=0; niceval="+1" # initialize while getopts "n:u:t:p" opt; do case $opt in n ) niceval="$OPTARG"; ;; ...
Get Wicked Cool Shell Scripts now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.