123HELPDESK

IT professionals voor ondernemers

Process terminate script PDF Afdrukken

Bash scrip to terminate processes:
 

#!/bin/ksh
if [ $# -gt 0 ]; then
process_name=$1
ps_count=`ps -ef | grep -v 'grep' | grep -v 'kill' | grep -i -c $process_name`
echo "Process count: $ps_count"
set -A array_name `ps -ef | grep -i $process_name | grep -v 'grep' | grep -v 'kill' | awk '{print $2}' | sort -u`
print "ps -ef | grep -i $process_name | grep -v 'grep' | grep -v 'kill' | awk '{print \$2 \$8}' | sort -u -n"

print "${array_name[*]}"
kill_count=0
while [ $kill_count -lt $ps_count ]
do
kill -9 ${array_name[$kill_count]}
# print "kill -15 ${array_name[$kill_count]}"
((kill_count=kill_count+1))
done

else
print "Usage: $0 process_name"
print ""
fi

 
Volgende >