实用脚本与 OS X 系统技巧
1. renicename 脚本
renicename 脚本的主要功能是对匹配指定名称的作业进行优先级调整。以下是该脚本的代码:
#!/bin/bash # 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"; ;; u ) if [ ! -z "$tty" ] ; then echo "$0: error: -u and -t are mutually exclusive." >&2 exit 1 fi user=$OPTARG ;; t ) if [ ! -z "$user" ] ; then echo "$0: error: -u and -t are mutually exclusive." >&2 exit 1 fi tty=$OPTARG ;; p ) showpid=1; ;; ? ) echo "Usage: $0 [-n niceval] [-u