
Dalam kesempatan kali ini saya akan menulis artikel pendek yaitu bagaimana cara Kill Sebuah proses PID yang terdapat ID PID dalam Sebuah File. Bagi kalian yang masih belum tau artinya apa itu PID, PID adalah Process ID, jadi setiap process yang berjalan pada system linux itu mempunya ID nah untuk melihat Task Manager process yang ada di Linux bisa dengan menjalankan Syntak
$ top
Setelah menjalankan syntak tersebut maka akan ada output seperti berikut ini :
Tasks: 156 total, 2 running, 154 sleeping, 0 stopped, 0 zombie
%Cpu(s): 0.5 us, 0.1 sy, 0.0 ni, 99.3 id, 0.1 wa, 0.0 hi, 0.0 si, 0.0 st
KiB Mem : 16165296 total, 15209056 free, 485424 used, 470816 buff/cache
KiB Swap: 31999996 total, 31999996 free, 0 used. 15304100 avail Mem
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
8128 apache 20 0 720648 26468 13360 S 1.2 0.2 0:00.45 httpd
7857 root 20 0 161996 2340 1592 R 0.8 0.0 0:01.07 top
1430 root 20 0 581704 29852 11796 S 0.4 0.2 1:02.54 docker-containe
1 root 20 0 190992 3920 2584 S 0.0 0.0 0:03.16 systemd
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
3 root 20 0 0 0 0 S 0.0 0.0 0:00.03 ksoftirqd/0
5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H
7 root rt 0 0 0 0 S 0.0 0.0 0:00.05 migration/0
8 root 20 0 0 0 0 S 0.0 0.0 0:00.00 rcu_bh
9 root 20 0 0 0 0 S 0.0 0.0 0:01.57 rcu_sched
10 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 lru-add-drain
11 root rt 0 0 0 0 S 0.0 0.0 0:00.14 watchdog/0
12 root rt 0 0 0 0 S 0.0 0.0 0:00.14 watchdog/1
13 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/1
14 root 20 0 0 0 0 S 0.0 0.0 0:00.01 ksoftirqd/1
16 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/1:0H
17 root rt 0 0 0 0 S 0.0 0.0 0:00.14 watchdog/2
18 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/2
19 root 20 0 0 0 0 S 0.0 0.0 0:00.09 ksoftirqd/2
21 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/2:0H
22 root rt 0 0 0 0 S 0.0 0.0 0:00.13 watchdog/3
23 root rt 0 0 0 0 S 0.0 0.0 0:00.00 migration/3
24 root 20 0 0 0 0 S 0.0 0.0 0:00.01 ksoftirqd/3
26 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/3:0H
28 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kdevtmpfs
29 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 netns
30 root 20 0 0 0 0 S 0.0 0.0 0:00.01 khungtaskd
31 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 writeback
32 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kintegrityd
33 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset
34 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset
35 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 bioset
36 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kblockd
37 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 md
38 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 edac-poller
39 root 20 0 0 0 0 S 0.0 0.0 0:02.60 kworker/0:1
44 root 20 0 0 0 0 S 0.0 0.0 0:00.00 kswapd0
45 root 25 5 0 0 0 S 0.0 0.0 0:00.00 ksmd
46 root 39 19 0 0 0 S 0.0 0.0 0:00.57 khugepaged
Semua detail informasi process ada, lalu bagaimana cara kill process yang berjalan. Dalam kasus ini saya ada PID dalam sebuah file dengan nama file program.pid dengan PID 3313 maka untuk kill process tersebut bisa dengan menjalankan syntak :
kill -9 `cat /var/run/program.pid`
Demikianlah artikel yang sangat singkat ini, semoga bermanfaat.
Comments