#!/bin/bash #LACKSETUP # Calm a process down # NEEDS_WORK: cleanup # calm == only one process # calm == all processes that match query # calm * == if used in proc or a folder with just PID files, if not you will get an error # calm .... OK # set's NICE value to 0 # need sudo PIDS=$@ errorFn() { echo calm: Invalid operation or no such PID/process \(\"$(echo "$PIDS" | tr '\n' ' ' | cut -c -20)...\"\) exit } for pid in $PIDS do # Process to PID in elegant way NEWPIDS=$(pidof "$pid") if [ "$NEWPIDS" ] then BINNY=$pid pid=$NEWPIDS else NEWBINS=$pid BINNY=$(ps -p "$pid" -o comm= 2>/dev/null ) if [ $? != 0 ] then errorFn fi fi echo Calming down $pid \("$BINNY"\)... sudo renice -n 0 -p $pid; done