Everything which happens on linux server is a process. For that reason, process management is a key skill for the administrators. Process can be classified into two parts –
- shell jobs (starts from the command line)
- Service Daemons
When the process starts, It can use multiple threads.
MANAGING SHELL JOBS
When the user types a command, a shell job is started as a foreground process, occupying the terminal.
RUNNING THE JOBS IN THE BACKGROUND AND FOREGROUND
Any command executed by you started in the foreground job. You can take two approaches to run a process in the background.
If you are sure that process will take a long time to complete, you can start with & behind it. It immediately starts the job in the background a creates a room for another command to run on the terminal.
1 2 |
[root@server1 ~]# dd if=/dev/zero of=/dev/null & [1] 4550 |
to move the last job that was started in the background use fg command
1 |
[root@server1 ~]# fg |
If your job is taking lot more time than expected, you can use ctl+z to temporary stop the job. It does remove from the memory, it just paused, it can be managed later. You can continue this paused job using bg command in the background. Alternate you can use ctrl+c key sequence to stop the job.
When a process started from a shell, it automatically becomes a child process of the current shell. Parent-Child relationship in processes is important. The parent process is required to manage all the child processes. If the shell is terminated then all the processes will stop. If you started processes from the current shell in the background, then they will not be killed, when the shell is terminated. You have to use the kill command to terminate that process which is running in the background.
All the tasks typically started in the Linux as processes. One process can start multiple worker threads. If the process is very busy then threads can be handled by different CPUs or CPU cores available in the machine. As an administrator, you can only manage process not thread. Each background process starts with a unique Process Identification Identified (PID). You can easily find the kernel thread because they have a name in square brackets. You can see kernel threads using the ps aux | head command. You can not manage the kernel threads even can not change the priority and kill.
1 2 3 4 5 6 7 8 9 10 11 |
[root@server1 ~]# ps aux | head USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.1 19348 1560 ? Ss 09:25 0:01 /sbin/init root 2 0.0 0.0 0 0 ? S 09:25 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? S 09:25 0:00 [migration/0] root 4 0.0 0.0 0 0 ? S 09:25 0:00 [ksoftirqd/0] root 5 0.0 0.0 0 0 ? S 09:25 0:00 [stopper/0] root 6 0.0 0.0 0 0 ? S 09:25 0:00 [watchdog/0] root 7 0.0 0.0 0 0 ? S 09:25 0:04 [events/0] root 8 0.0 0.0 0 0 ? S 09:25 0:00 [events/0] root 9 0.0 0.0 0 0 ? S 09:25 0:00 [events_long/0] |
GET CURRENTLY STARTED BY CURRENT USER
If you run ps command with any option, it displays currently started processes by the user.
1 2 3 4 |
[root@server1 ~]# ps PID TTY TIME CMD 5615 pts/2 00:00:00 bash 5638 pts/2 00:00:00 ps |
look for a short summary of active processes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
[root@server1 ~]# ps aux USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND root 1 0.0 0.1 19348 1560 ? Ss 10:02 0:01 /sbin/init root 2 0.0 0.0 0 0 ? S 10:02 0:00 [kthreadd] root 3 0.0 0.0 0 0 ? S 10:02 0:00 [migration/0] root 4 0.0 0.0 0 0 ? S 10:02 0:00 [ksoftirqd/0] root 5 0.0 0.0 0 0 ? S 10:02 0:00 [stopper/0] root 6 0.0 0.0 0 0 ? S 10:02 0:00 [watchdog/0] root 7 0.0 0.0 0 0 ? S 10:02 0:06 [events/0] root 8 0.0 0.0 0 0 ? S 10:02 0:00 [events/0] root 9 0.0 0.0 0 0 ? S 10:02 0:00 [events_long/0] root 10 0.0 0.0 0 0 ? S 10:02 0:00 [events_power_ef] root 11 0.0 0.0 0 0 ? S 10:02 0:00 [cgroup] root 12 0.0 0.0 0 0 ? S 10:02 0:00 [khelper] root 13 0.0 0.0 0 0 ? S 10:02 0:00 [netns] root 14 0.0 0.0 0 0 ? S 10:02 0:00 [async/mgr] root 15 0.0 0.0 0 0 ? S 10:02 0:00 [pm] root 16 0.0 0.0 0 0 ? S 10:02 0:00 [sync_supers] root 17 0.0 0.0 0 0 ? S 10:02 0:00 [bdi-default] root 18 0.0 0.0 0 0 ? S 10:02 0:00 [kintegrityd/0] root 19 0.0 0.0 0 0 ? S 10:02 0:01 [kblockd/0] root 20 0.0 0.0 0 0 ? S 10:02 0:00 [kacpid] root 21 0.0 0.0 0 0 ? S 10:02 0:00 [kacpi_notify] root 22 0.0 0.0 0 0 ? S 10:02 0:00 [kacpi_hotplug] root 23 0.0 0.0 0 0 ? S 10:02 0:00 [ata_aux] root 24 0.0 0.0 0 0 ? S 10:02 0:01 [ata_sff/0] root 25 0.0 0.0 0 0 ? S 10:02 0:00 [ksuspend_usbd] root 26 0.0 0.0 0 0 ? S 10:02 0:00 [khubd] root 27 0.0 0.0 0 0 ? S 10:02 0:00 [kseriod] root 28 0.0 0.0 0 0 ? S 10:02 0:00 [md/0] root 29 0.0 0.0 0 0 ? S 10:02 0:00 [md_misc/0] root 30 0.0 0.0 0 0 ? S 10:02 0:00 [linkwatch] root 33 0.0 0.0 0 0 ? S 10:02 0:00 [khungtaskd] root 34 0.0 0.0 0 0 ? S 10:02 0:00 [kswapd0] root 35 0.0 0.0 0 0 ? SN 10:02 0:00 [ksmd] root 36 0.0 0.0 0 0 ? SN 10:02 0:00 [khugepaged] root 37 0.0 0.0 0 0 ? S 10:02 0:00 [aio/0] root 38 0.0 0.0 0 0 ? S 10:02 0:00 [crypto/0] root 45 0.0 0.0 0 0 ? S 10:02 0:00 [kthrotld/0] root 46 0.0 0.0 0 0 ? S 10:02 0:00 [pciehpd] root 48 0.0 0.0 0 0 ? S 10:02 0:00 [kpsmoused] root 49 0.0 0.0 0 0 ? S 10:02 0:00 [usbhid_resumer] root 50 0.0 0.0 0 0 ? S 10:02 0:00 [deferwq] root 83 0.0 0.0 0 0 ? S 10:02 0:00 [kdmremove] root 84 0.0 0.0 0 0 ? S 10:02 0:00 [kstriped] root 115 0.0 0.0 0 0 ? S 10:02 0:00 [ttm_swap] root 252 0.0 0.0 0 0 ? S 10:02 0:00 [scsi_eh_0] root 254 0.0 0.0 0 0 ? S 10:02 0:00 [scsi_eh_1] root 261 0.0 0.0 0 0 ? S 10:02 0:00 [mpt_poll_0] root 262 0.0 0.0 0 0 ? S 10:02 0:00 [mpt/0] root 263 0.0 0.0 0 0 ? S 10:02 0:00 [scsi_eh_2] root 393 0.0 0.0 0 0 ? S 10:02 0:00 [kdmflush] root 395 0.0 0.0 0 0 ? S 10:02 0:00 [kdmflush] root 461 0.0 0.0 0 0 ? S 10:02 0:00 [jbd2/dm-0-8] root 462 0.0 0.0 0 0 ? S 10:02 0:00 [ext4-dio-unwrit] root 561 0.0 0.1 11284 1420 ? S<s 10:02 0:00 /sbin/udevd -d root 993 0.0 0.0 0 0 ? S 10:02 0:00 [vmmemctl] root 1158 0.0 0.0 0 0 ? S 10:02 0:00 [jbd2/sda1-8] root 1159 0.0 0.0 0 0 ? S 10:02 0:00 [ext4-dio-unwrit] root 1205 0.0 0.0 0 0 ? S 10:02 0:00 [kauditd] root 1294 0.0 0.0 0 0 ? S 10:02 0:00 [flush-253:0] root 1608 0.0 0.1 184640 1072 ? Ssl 10:02 0:00 /usr/sbin/vmware-vmblock-fuse -o subt root 1644 0.1 0.8 251448 8320 ? Sl 10:02 0:09 /usr/sbin/vmtoolsd root 1699 0.0 1.0 59972 10172 ? S 10:02 0:00 /usr/lib/vmware-vgauth/VGAuthService root 1788 0.0 0.8 521760 8040 ? Sl 10:02 0:06 //usr/lib/vmware-caf/pme/bin/Manageme root 1844 0.0 0.0 0 0 ? S 10:02 0:00 [ib_addr] root 1849 0.0 0.0 0 0 ? S 10:02 0:00 [infiniband/0] root 1858 0.0 0.0 0 0 ? S 10:02 0:00 [ib_mcast] root 1863 0.0 0.0 0 0 ? S 10:02 0:00 [iw_cm_wq] root 1868 0.0 0.0 0 0 ? S 10:02 0:00 [ib_cm/0] root 1873 0.0 0.0 0 0 ? S 10:02 0:00 [rdma_cm] root 1894 0.0 0.0 0 0 ? S 10:02 0:00 [ipoib_flush] root 2128 0.0 0.0 29768 876 ? S<sl 10:02 0:00 auditd root 2162 0.0 0.1 249160 1748 ? Sl 10:02 0:00 /sbin/rsyslogd -i /var/run/syslogd.pi rpc 2213 0.0 0.0 18980 892 ? Ss 10:02 0:00 rpcbind dbus 2233 0.0 0.1 32112 1548 ? Ssl 10:02 0:00 dbus-daemon --system rpcuser 2256 0.0 0.1 23352 1376 ? Ss 10:02 0:00 rpc.statd root 2300 0.0 0.3 189084 3380 ? Ss 10:02 0:00 cupsd -C /etc/cups/cupsd.conf root 2332 0.0 0.0 4080 656 ? Ss 10:02 0:00 /usr/sbin/acpid 68 2344 0.0 0.5 39400 5652 ? Ssl 10:02 0:00 hald root 2345 0.0 0.1 20400 1208 ? S 10:02 0:00 hald-runner root 2392 0.0 0.1 22520 1112 ? S 10:02 0:00 hald-addon-input: Listening on /dev/i 68 2395 0.0 0.1 18008 1056 ? S 10:02 0:00 hald-addon-acpi: listening on acpid s root 2396 0.0 0.1 22516 1136 ? S 10:02 0:02 hald-addon-storage: polling /dev/sr0 root 2425 0.0 0.1 91276 1596 ? Ssl 10:02 0:00 pcscd root 2444 0.0 0.1 452720 1968 ? Ssl 10:02 0:00 automount --pid-file /var/run/autofs. root 2489 0.0 0.1 66260 1200 ? Ss 10:02 0:00 /usr/sbin/sshd root 2665 0.0 0.3 80956 3468 ? Ss 10:02 0:00 /usr/libexec/postfix/master postfix 2670 0.0 0.3 81204 3600 ? S 10:02 0:00 qmgr -l -t fifo -u root 2679 0.0 0.2 182908 2380 ? Ss 10:02 0:00 /usr/sbin/abrtd root 2706 0.0 0.1 116888 1408 ? Ss 10:02 0:01 crond root 2721 0.0 0.0 21108 496 ? Ss 10:02 0:00 /usr/sbin/atd root 2737 0.0 0.1 64420 1432 ? Ss 10:02 0:00 /usr/sbin/certmonger -S -p /var/run/c root 2766 0.0 0.2 134024 2164 ? Ssl 10:02 0:00 /usr/sbin/gdm-binary -nodaemon root 2782 0.0 0.0 4064 540 tty2 Ss+ 10:02 0:00 /sbin/mingetty /dev/tty2 root 2784 0.0 0.0 4064 548 tty3 Ss+ 10:02 0:00 /sbin/mingetty /dev/tty3 root 2786 0.0 0.0 4064 544 tty4 Ss+ 10:02 0:00 /sbin/mingetty /dev/tty4 root 2788 0.0 0.0 4064 548 tty5 Ss+ 10:02 0:00 /sbin/mingetty /dev/tty5 root 2793 0.0 0.0 4064 544 tty6 Ss+ 10:02 0:00 /sbin/mingetty /dev/tty6 root 2813 0.0 0.3 164700 3084 ? Sl 10:02 0:00 /usr/libexec/gdm-simple-slave --displ root 2816 0.0 2.1 165800 21292 tty1 Ss+ 10:02 0:00 /usr/bin/Xorg :0 -br -verbose -audit root 2830 0.0 0.3 577712 3260 ? Sl 10:02 0:00 /usr/sbin/console-kit-daemon --no-dae gdm 2900 0.0 0.0 20068 688 ? S 10:02 0:00 /usr/bin/dbus-launch --exit-with-sess gdm 2901 0.0 0.1 31812 1272 ? Ssl 10:02 0:00 /bin/dbus-daemon --fork --print-pid 5 gdm 2903 0.0 0.7 273768 7972 ? Ssl 10:02 0:00 /usr/bin/gnome-session --autostart=/u root 2906 0.0 0.2 49988 2712 ? S 10:02 0:00 /usr/libexec/devkit-power-daemon gdm 2912 0.0 0.5 133548 5528 ? S 10:02 0:00 /usr/libexec/gconfd-2 gdm 2926 0.0 0.4 120752 4444 ? S 10:02 0:00 /usr/libexec/at-spi-registryd gdm 2930 0.0 1.3 368364 13228 ? Ssl 10:02 0:00 /usr/libexec/gnome-settings-daemon -- gdm 2932 0.0 0.5 358624 5056 ? Ssl 10:02 0:00 /usr/libexec/bonobo-activation-server gdm 2939 0.0 0.1 135300 1880 ? S 10:02 0:00 /usr/libexec/gvfsd gdm 2940 0.0 0.9 297836 10020 ? S 10:02 0:00 metacity gdm 2942 0.0 1.6 393456 16172 ? S 10:02 0:00 /usr/libexec/gdm-simple-greeter gdm 2943 0.0 0.8 273888 8680 ? S 10:02 0:00 gnome-power-manager gdm 2944 0.0 0.7 248352 7476 ? S 10:02 0:00 /usr/libexec/polkit-gnome-authenticat root 2951 0.0 0.4 53008 4744 ? S 10:02 0:00 /usr/libexec/polkit-1/polkitd gdm 2956 0.0 0.4 427224 4260 ? S<sl 10:02 0:00 /usr/bin/pulseaudio --start --log-tar rtkit 2958 0.0 0.1 168456 1196 ? SNl 10:02 0:00 /usr/libexec/rtkit-daemon root 2964 0.0 0.2 141796 2068 ? S 10:02 0:00 pam: gdm-password root 2969 0.0 0.4 102092 4492 ? Ss 10:02 0:00 sshd: root@pts/0 root 2974 0.0 0.1 108460 1896 pts/0 Ss+ 10:02 0:00 -bash root 3421 0.0 0.0 0 0 ? S 10:18 0:00 [kdmflush] root 3845 0.0 0.0 0 0 ? S 10:33 0:00 [jbd2/dm-2-8] root 3847 0.0 0.0 0 0 ? S 10:33 0:00 [ext4-dio-unwrit] root 3857 0.0 0.1 11288 1648 ? S< 10:33 0:00 /sbin/udevd -d root 3858 0.0 0.1 11280 1640 ? S< 10:33 0:00 /sbin/udevd -d root 5035 0.0 0.4 102092 4444 ? Ss 11:23 0:00 sshd: root@pts/1 root 5039 0.0 0.1 108360 1820 pts/1 Ss+ 11:23 0:00 -bash postfix 5531 0.0 0.3 81036 3488 ? S 11:50 0:00 pickup -l -t fifo -u postfix 5548 0.0 0.3 81180 3600 ? S 11:50 0:00 cleanup -z -t unix -u postfix 5549 0.0 0.4 81336 4172 ? S 11:50 0:00 local -t unix postfix 5550 0.0 0.3 81180 3604 ? S 11:50 0:00 cleanup -z -t unix -u postfix 5551 0.0 0.4 81336 4168 ? S 11:50 0:00 local -t unix postfix 5565 0.0 0.3 81044 3452 ? S 11:51 0:00 trivial-rewrite -n rewrite -t unix -u root 5611 0.0 0.4 102092 4444 ? Ss 11:53 0:00 sshd: root@pts/2 root 5615 0.0 0.1 108360 1840 pts/2 Ss 11:53 0:00 -bash root 5723 8.0 0.1 110256 1148 pts/2 R+ 11:58 0:00 ps aux |
if you are not looking only for the name of the process but also for the exact command that was used to start the process
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
[root@server1 ~]# ps -ef UID PID PPID C STIME TTY TIME CMD root 1 0 0 10:02 ? 00:00:01 /sbin/init root 2 0 0 10:02 ? 00:00:00 [kthreadd] root 3 2 0 10:02 ? 00:00:00 [migration/0] root 4 2 0 10:02 ? 00:00:00 [ksoftirqd/0] root 5 2 0 10:02 ? 00:00:00 [stopper/0] root 2162 1 0 10:02 ? 00:00:00 /sbin/rsyslogd -i /var/run/syslogd.pid -c 5 rpc 2213 1 0 10:02 ? 00:00:00 rpcbind dbus 2233 1 0 10:02 ? 00:00:00 dbus-daemon --system rpcuser 2256 1 0 10:02 ? 00:00:00 rpc.statd root 2300 1 0 10:02 ? 00:00:00 cupsd -C /etc/cups/cupsd.conf root 2332 1 0 10:02 ? 00:00:00 /usr/sbin/acpid 68 2344 1 0 10:02 ? 00:00:00 hald root 2345 2344 0 10:02 ? 00:00:00 hald-runner root 2392 2345 0 10:02 ? 00:00:00 hald-addon-input: Listening on /dev/input/event0 /dev 68 2395 2345 0 10:02 ? 00:00:00 hald-addon-acpi: listening on acpid socket /var/run/a root 2396 2345 0 10:02 ? 00:00:02 hald-addon-storage: polling /dev/sr0 (every 2 sec) root 2425 1 0 10:02 ? 00:00:00 pcscd root 2444 1 0 10:02 ? 00:00:00 automount --pid-file /var/run/autofs.pid root 2489 1 0 10:02 ? 00:00:00 /usr/sbin/sshd root 2665 1 0 10:02 ? 00:00:00 /usr/libexec/postfix/master postfix 2670 2665 0 10:02 ? 00:00:00 qmgr -l -t fifo -u root 2679 1 0 10:02 ? 00:00:00 /usr/sbin/abrtd root 2706 1 0 10:02 ? 00:00:01 crond root 2721 1 0 10:02 ? 00:00:00 /usr/sbin/atd root 2737 1 0 10:02 ? 00:00:00 /usr/sbin/certmonger -S -p /var/run/certmonger.pid root 2766 1 0 10:02 ? 00:00:00 /usr/sbin/gdm-binary -nodaemon root 2782 1 0 10:02 tty2 00:00:00 /sbin/mingetty /dev/tty2 root 2784 1 0 10:02 tty3 00:00:00 /sbin/mingetty /dev/tty3 root 2786 1 0 10:02 tty4 00:00:00 /sbin/mingetty /dev/tty4 root 2788 1 0 10:02 tty5 00:00:00 /sbin/mingetty /dev/tty5 postfix 5549 2665 0 11:50 ? 00:00:00 local -t unix postfix 5550 2665 0 11:50 ? 00:00:00 cleanup -z -t unix -u postfix 5551 2665 0 11:50 ? 00:00:00 local -t unix postfix 5565 2665 0 11:51 ? 00:00:00 trivial-rewrite -n rewrite -t unix -u root 5611 2489 0 11:53 ? 00:00:00 sshd: root@pts/2 root 5615 5611 0 11:53 pts/2 00:00:00 -bash root 5831 5615 0 12:03 pts/2 00:00:00 ps -ef |
looking for the parent-child relationship
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
2766 ? Ssl 0:00 /usr/sbin/gdm-binary -nodaemon 2813 ? Sl 0:00 \_ /usr/libexec/gdm-simple-slave --display-id /org/gnome/DisplayManager/Di 2816 tty1 Ss+ 0:00 \_ /usr/bin/Xorg :0 -br -verbose -audit 4 -auth /var/run/gdm/auth-for- 2903 ? Ssl 0:00 \_ /usr/bin/gnome-session --autostart=/usr/share/gdm/autostart/LoginWi 2926 ? S 0:00 | \_ /usr/libexec/at-spi-registryd 2940 ? S 0:00 | \_ metacity 2942 ? S 0:00 | \_ /usr/libexec/gdm-simple-greeter 2943 ? S 0:00 | \_ gnome-power-manager 2944 ? S 0:00 | \_ /usr/libexec/polkit-gnome-authentication-agent-1 2964 ? S 0:00 \_ pam: gdm-password 2782 tty2 Ss+ 0:00 /sbin/mingetty /dev/tty2 2784 tty3 Ss+ 0:00 /sbin/mingetty /dev/tty3 2786 tty4 Ss+ 0:00 /sbin/mingetty /dev/tty4 2788 tty5 Ss+ 0:00 /sbin/mingetty /dev/tty5 2793 tty6 Ss+ 0:00 /sbin/mingetty /dev/tty6 2830 ? Sl 0:00 /usr/sbin/console-kit-daemon --no-daemon 2900 ? S 0:00 /usr/bin/dbus-launch --exit-with-session 2901 ? Ssl 0:00 /bin/dbus-daemon --fork --print-pid 5 --print-address 7 --session 2906 ? S 0:00 /usr/libexec/devkit-power-daemon 2912 ? S 0:00 /usr/libexec/gconfd-2 2930 ? Ssl 0:00 /usr/libexec/gnome-settings-daemon --gconf-prefix=/apps/gdm/simple-greeter/ 2932 ? Ssl 0:00 /usr/libexec/bonobo-activation-server --ac-activate --ior-output-fd=12 2939 ? S 0:00 /usr/libexec/gvfsd 2951 ? S 0:00 /usr/libexec/polkit-1/polkitd 2956 ? S<sl 0:00 /usr/bin/pulseaudio --start --log-target=syslog 2958 ? SNl 0:00 /usr/libexec/rtkit-daemon |
get process id by the process name. For example – Web server Apache is running on my machine.
1 2 3 4 5 6 7 8 9 10 11 |
[root@server1 ~]# ps aux | grep httpd root 5964 0.1 0.3 186116 3976 ? Ss 12:10 0:00 /usr/sbin/httpd apache 5967 0.0 0.2 186116 2536 ? S 12:10 0:00 /usr/sbin/httpd apache 5968 0.0 0.2 186116 2512 ? S 12:10 0:00 /usr/sbin/httpd apache 5969 0.0 0.2 186116 2512 ? S 12:10 0:00 /usr/sbin/httpd apache 5970 0.0 0.2 186116 2512 ? S 12:10 0:00 /usr/sbin/httpd apache 5971 0.0 0.2 186116 2512 ? S 12:10 0:00 /usr/sbin/httpd apache 5972 0.0 0.2 186116 2512 ? S 12:10 0:00 /usr/sbin/httpd apache 5973 0.0 0.2 186116 2512 ? S 12:10 0:00 /usr/sbin/httpd apache 5974 0.0 0.2 186116 2512 ? S 12:10 0:00 /usr/sbin/httpd root 5977 0.0 0.0 103332 852 pts/2 S+ 12:10 0:00 grep httpd |
or
1 2 3 4 5 6 7 8 9 10 |
[root@server1 ~]# pgrep httpd 5964 5967 5968 5969 5970 5971 5972 5973 5974 |
ADJUST PROCESS PRIORITY
When linux processes are started, they are started with the specified priority. By default, all processes are equal and started with equal priority 20. If you have to need to change the priority, use nice and renice commands.
If you want to start a process with adjusted priority, use nice command and want to adjust the priority of an already running process, use renice command. You can also use r option with the top command to adjust the priority.
If you are thinking to adjust priority using nice or renice command, you can select values ranging from -20 to 19. The default niceness of a process is set to 0 (which results in the priority value of 20). By applying a negative niceness, you increase the priority. Use a positive niceness to decrease the priority. It is a good idea not to use the
ultimate values immediately. Instead, use increments of 5 and see how it affects the application.
1 2 3 |
[root@server1 ~]# nice -n 5 dd if=/dev/zero of=/dev/null & [1] 6261 [root@server1 ~]# |
KILL PROCESS USING KILL AND PKILL
used uses PID to kill the process. First get the process is using ps aux | grep <process> or pgrep <processname>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[root@server1 ~]# pgrep dd 2 1844 2392 2395 2396 6353 [root@server1 ~]# kill 6353 [root@server1 ~]# pgrep dd 2 1844 2392 2395 2396 [1]+ Terminated nice -n 5 dd if=/dev/zero of=/dev/null |
LINUX PROCESS STATES
State | Description |
R (Running) | The process is currently active and using CPU |
S (Sleeping) | The process is wating for event |
Z (Zombie) | The process has been stopped but could not be removed by the parent, which has put it is in an unmanageable state |
Leave a Reply