6
process=xxxyyyzzz # Use nonexistent process.
7
# For demo purposes only...
8
# ... don't want to actually kill any actual process with this script.
10
# If, for example, you wanted to use this script to logoff the Internet,
13
t=`pidof $process` # Find pid (process id) of $process.
14
# The pid is needed by 'kill' (can't 'kill' by program name).
16
if [ -z "$t" ] # If process not present, 'pidof' returns null.
18
echo "Process $process was not running."
19
echo "Nothing killed."
23
kill $t # May need 'kill -9' for stubborn process.
25
# Need a check here to see if process allowed itself to be killed.
26
# Perhaps another " t=`pidof $process` " or ...
29
# This entire script could be replaced by
30
# kill $(pidof -x process_name)
32
# killall process_name
33
# but it would not be as instructive.