Freeing a terminal taken over by processes
You can stop stalled or unwanted process.
Identify and stop stalled or unwanted processes by doing the following:
- Determine the active processes running on the screen by
typing the following ps command:
ps -ef | pg
The ps command shows the process status. The -e flag writes information about all processes (except kernel processes), and the f flag generates a full listing of processes including what the command name and parameters were when the process was created. The pg command limits output to a single page at a time, so information does not quickly scroll off the screen.Suspicious processes include system or user processes that use up excessive amounts of a system resource such as CPU or disk space. System processes such as sendmail, routed, and lpd frequently become runaways. Use the ps -u command to check CPU usage.
- Determine who is running processes on this machine by
using the who command:
who
The who command displays information about all users currently on this system, such as login name, workstation name, date, and time of login. - Determine if you need to stop, suspend, or change the
priority of a user process. Note: You must have root authority to stop processes other than your own. If you terminate or change the priority of a user process, contact the process owner and explain what you have done.
- Stop the process using the kill command.
For example:
kill 1883
The kill command sends a signal to a running process. To stop a process, specify the process ID (PID), which is 1883 in this example. Use the ps command to determine the PID number of commands.
- Suspend the process and run it in the background by using the
ampersand (&). For example:
/u/bin1/prog1 &
The & signals that you want this process to run in the background. In a background process, the shell does not wait for the command to complete before returning the shell prompt. When a process requires more than a few seconds to complete, run the command in background by typing an & at the end of the command line. Jobs running in the background appear in the normal ps command.
- Change the priority of the processes that have taken over by
using the following renice command:
renice 20 1883
The renice command alters the scheduling priority of one or more running processes. The higher the number, the lower the priority with 20 being the lowest priority.
In the previous example, renice reschedules process number 1883 to the lowest priority. It will run when there is a small amount of unused processor time available.
- Stop the process using the kill command.
For example: