First versions of the binaries and source file.
This commit is contained in:
parent
d2630d6e4f
commit
1dfda10ddc
11 changed files with 742 additions and 0 deletions
37
calm
Executable file
37
calm
Executable file
|
|
@ -0,0 +1,37 @@
|
|||
#!/bin/bash
|
||||
#LACKSETUP
|
||||
# Calm a process down
|
||||
# NEEDS_WORK: cleanup
|
||||
# calm <pid> == only one process
|
||||
# calm <bin> == 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 <pid> <bin> .... 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue