Archive for the tag 'processes'

Kill all processes matching certain strings.

This guide will help you to know how to kill all processes matching certain strings, for our example we will use httpd.

One very simple method is killall, such as

killall -9 httpd

If that doesn’t work you can go through the process list and kill -9 the pids by using the following,

kill -9 $(ps aux | grep -v grep | grep httpd | awk ‘{print $2}’)

Where httpd is the string.

renice — alter priority of running processes

Renice alters the scheduling priority of one or more running processes. The following who parameters are interpreted as process ID’s, process group ID’s, or user names. a process group causes all processes in the process group to have their scheduling priority altered. a user causes all processes owned by the user to have their scheduling priority altered. By default, the processes to be affected are specified by their process ID’s.

For example,

renice +1 987 -u daemon root -p 32

would change the priority of process ID’s 987 and 32, and all processes owned by users daemon and root.

Users other than the super-user may only alter the priority of processes they own, and can only monotonically increase their “nice value” within the range 0 to PRIO_MAX (20). (This prevents overriding administrative fiats.) The super-user may alter the priority of any process and set the priority to any value in the range PRIO_MIN (?20) to PRIO_MAX. Useful priorities are: 20 (the affected processes will run only when nothing else in the system wants to), 0 (the “base” scheduling priority), anything negative (to make things go very fast).

SB-Shibu

Some common Linux kernel processes

Some common Linux kernel processes

kjournald Commits ext3 journal updates to disk
kswapd Swaps processes when physical memory is low
kreclaimd Reclaims memory pages that haven’t been used recently
ksoftirqd Handles multiple layers of soft interrupts
khubd Configures USB devices

There is one kjournald for each mounted ext3 filesystem.

Among these processes, only init is really a full-fledged user process. The others are actually portions of the kernel that have been dressed up to look like processes for scheduling or architectural reasons.

SB-Shibu

Peeking at the processes

Peeking at the processes

This example uses two parameters, the -e parameter, which shows all of the processes running on the system, and the -f parameter, which expands the output to show a few useful columns of information:

UID: The user responsible for launching the process
PID: The process ID of the process
PPID: The PID of the parent process (if a process is started by another process)
C: Processor utilization over the lifetime of the process
STIME: The system time when the process started
TTY: The terminal device from which the process was launched

root@dell:/etc# ps -ef |less |head -n 1
UID PID PPID C STIME TTY TIME CMD
root@dell:/etc# ps -ef |less |grep -i terminal
jyothis 3889 3271 0 08:49 ? 00:00:07 xfce4-terminal
root 4261 3996 0 09:42 pts/0 00:00:00 grep -i terminal

TIME: The cumulative CPU time required to run the process
CMD: The name of the program that was started

SB-Shibu

/etc/inittab parent of all processes

Init is the parent of all processes. Its primary role is to create processes from a script stored in the file /etc/inittab.

Some Linux implementations contain a table of processes to start automatically on bootup. On Linux systems this table is usually located in the special file /etc/inittab.

The Linux operating system uses an init system that utilizes run levels. A run level can be used to
direct the init process to run only certain types of processes, as defined in the /etc/inittab file. There are five init run levels in the Linux operating system.

At run level 1, only the basic system processes are started, along with one console terminal process. This is called single user mode. Single user mode is most often used for emergency filesystem maintenance when something is broken. Obviously, in this mode only one person (usually the
administrator) can log in to the system to manipulate data.

# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.

Next »