在top命令下kill和renice进程

时间:2023-03-08 20:29:58
在top命令下kill和renice进程

For common process management tasks, top is so great because it gives an overview of the most active processes currently running (hence the name top). This enables you to easily find processes that might need attention. From top, you can also perform common process management tasks, such as adjusting the current process priority and killing processes.

[root@rhel7 ~]# top

top - :: up  min,   user,  load average: 0.00, 0.01, 0.05
Tasks: total, running, sleeping, stopped, zombie
%Cpu(s): 0.0 us, 0.0 sy, 0.0 ni,100.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : total, free, used, buff/cache
KiB Swap: total, free, used. avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
root S 0.0 0.4 :01.61 systemd
root S 0.0 0.0 :00.00 kthreadd
root S 0.0 0.0 :00.01 ksoftirqd/
root rt S 0.0 0.0 :00.00 migration/
root S 0.0 0.0 :00.00 rcu_bh
root S 0.0 0.0 :00.00 rcuob/
root S 0.0 0.0 :00.66 rcu_sched
root R 0.0 0.0 :00.30 rcuos/
root rt S 0.0 0.0 :00.02 watchdog/
root - S 0.0 0.0 :00.00 khelper
root S 0.0 0.0 :00.00 kdevtmpfs
root - S 0.0 0.0 :00.00 netns
root - S 0.0 0.0 :00.00 perf
root - S 0.0 0.0 :00.00 writeback
root - S 0.0 0.0 :00.00 kintegrityd
root - S 0.0 0.0 :00.00 bioset
root - S 0.0 0.0 :00.00 kblockd
root - S 0.0 0.0 :00.00 md
root S 0.0 0.0 :01.04 kworker/:
root S 0.0 0.0 :00.00 khungtaskd
root S 0.0 0.0 :00.00 kswapd0
root S 0.0 0.0 :00.00 ksmd
root S 0.0 0.0 :00.01 khugepaged
root S 0.0 0.0 :00.00 fsnotify_mark
root - S 0.0 0.0 :00.00 crypto
root - S 0.0 0.0 :00.00 kthrotld
root - S 0.0 0.0 :00.00 kmpath_rdacd
root - S 0.0 0.0 :00.00 kpsmoused
root - S 0.0 0.0 :00.00 ipv6_addrconf
root - S 0.0 0.0 :00.00 deferwq
root S 0.0 0.0 :00.00 kauditd
root - S 0.0 0.0 :00.00 ata_sff

在top命令下kill和renice进程

Now that you know how to use the  kill  and  nice  commands from the command line, using the same functionality from top is even easier. From top, type  k . top will then prompt for the PID of the process you want to send a signal to. By default, the most active process is selected. After you enter the PID, top asks which signal you want to send. By default, signal 15 for SIGTERM is used. However, if you want to insist a bit more, you can type  9  for SIGKILL. Now press  Enter  to terminate the process.

To renice a running process from top, type  r . You are first prompted for the PID of the process you want to renice. After entering the PID, you are prompted for the nice value you want to use. Enter a positive value to increase process priority or a negative value to decrease process priority.