| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Linux is renowned for its stability, and it's true that the operating system itself seldom crashes or hangs. The programs you run on it however, might not be so sturdy, and some programs can and do crash. Unlike some other operating systems, Linux itself is rarely affected by crashing programs.Recovery is normally fairly easy, and reboots are very rarely required.
17.1 Terminating Misbehaving Programs
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
xkill, either from your menus or an Xterminal window, and
the mouse cursor will change into something resembling a gunsight. Move
the cursor over the offending window and click on it; this will usually
shut down the problem program.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
ps command is an extremely useful tool that is run from the
command line to list all the processes currently running. It can be used
in conjunction with the kill command to stop crashed or runaway
programs. To use it, open an xterminal and type in: ps -aux. The
-aux option just makes ps show some additional information.
You'll be presented with a list of all the running processes, their
owners, their resource usage and so on. On the extreme left side you'll
see the identifying number (or PID) of each process. This number can be
used with the kill command to stop rogue programs.
As an example, we'll assume Netscape has crashed, and can't be shutdown
normally. Running ps -aux shows up Netscape in the list of
running processes, along with Netscapes PID or process identifying
number (let's say the PID is 2345). Typing in this:
kill 2345
should stop Netscape immediately. Run ps -aux again to see if it
has indeed been killed. What if it's still there? Run the kill command
again, but this time with the -9 option, eg.
kill -9 2345
should do the trick.
The kill command (without the -9) should always be tried first,
as it gives the process a chance to close any files it may have open and
generally tidy up after itself, whereas kill -9 is not so gentle
and just kills the process instantly. Note that the 2345 PID I've used
is just an example, and that each process is allocated a PID number when
it is started.
There is another version of kill, and that is killall. The
killall command is used with the processes name, rather than
PID. For example:
killall netscape
or
killall -9
netscape
could be used when you know the processes name.
The ps -aux command is also handy for spotting resource
hogs. Let's say for example you are working at your computer when you
notice things are slowing to a crawl. Run ps-aux and check the
columns showing the cpu and memory usage to spot the offending
program. You can then use kill to terminate it if you wish.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
ps -aux when X restarts just
to make sure the crashed program didn't leave any leftover
processes. These should be killed before restarting them in the new X
session.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
| [ << ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |