January 2004
Intermediate to advanced
368 pages
7h 25m
English
Linux and some Unixes have a very helpful command called killall, which allows you to kill all running applications that match a specified pattern. It can be quite helpful when you want to kill nine mingetty daemons, or even just to send a SIGHUP signal to xinetd to prompt it to reread its configuration file. Systems that don't have killall can emulate it in a shell script, built around ps for identification of matching processes and kill to send the specified signal.
The tricky part of the script is that the output format from ps varies significantly from OS to OS. For example, consider how differently Mac OS X and Red Hat Linux show running processes in the default ps output:
OSX $ ps PID TT STAT TIME COMMAND ...
Read now
Unlock full access