Friday, April 22, 2005

change nice level to -1, and sudoers

Credit to Norm for this beauty. Here's the latest JEdit script to change the nice level to -1:

#!/bin/sh
# Java heap size, in megabytes
JAVA_HEAP_SIZE=256
DEFAULT_JAVA_HOME="/opt/sun-jdk-1.4.2.06/jre"
if [ "$JAVA_HOME" = "" ]; then
JAVA_HOME="$DEFAULT_JAVA_HOME"
fi
#exec "$JAVA_HOME/bin/java" -mx${JAVA_HEAP_SIZE}m ${JEDIT} -jar "/home/russ/jedit/4.3pre1/jedit.jar" $@
#exec "$JAVA_HOME/bin/java" -mx${JAVA_HEAP_SIZE}m ${JEDIT} -jar "/home/russ/jedit/4.3pre2/jedit.jar" $@
#exec "$JAVA_HOME/bin/java" -mx${JAVA_HEAP_SIZE}m ${JEDIT} -jar "/home/russ/jedit/4.2/jedit.jar" $@
#----speedup code----#
"$JAVA_HOME/bin/java" -mx${JAVA_HEAP_SIZE}m ${JEDIT} -jar "/home/russ/jedit/4.3pre2/jedit.jar" $@ > /dev/null 2>&1 &
jeditPid=$!
sleep 10
jeditPid2=`ps axl|grep $jeditPid|awk '{print $3}'`
for pid in $jeditPid2
do
jeditPid3=`ps axl|grep $pid|awk '{print $3}'`
for realPid in $jeditPid3
do
sudo /usr/bin/renice -1 $realPid > /dev/null 2>&1 &
done
done

New stuff is everything under "speedup code#". In order to enable this to work correctly, sudoers must be modified. Current sudoers is as follows:

russ ALL = NOPASSWD:/usr/bin/renice

No comments: